diff --git a/3rdparty/taglib/ape/apefile.cpp b/3rdparty/taglib/ape/apefile.cpp index 6d598139b..56330005d 100644 --- a/3rdparty/taglib/ape/apefile.cpp +++ b/3rdparty/taglib/ape/apefile.cpp @@ -46,25 +46,22 @@ using namespace Strawberry_TagLib::TagLib; -namespace -{ - enum { ApeAPEIndex = 0, ApeID3v1Index = 1 }; +namespace { +enum { ApeAPEIndex = 0, + ApeID3v1Index = 1 }; } -class APE::File::FilePrivate -{ -public: - FilePrivate() : - APELocation(-1), - APESize(0), - ID3v1Location(-1), - ID3v2Header(0), - ID3v2Location(-1), - ID3v2Size(0), - properties(0) {} +class APE::File::FilePrivate { + public: + FilePrivate() : APELocation(-1), + APESize(0), + ID3v1Location(-1), + ID3v2Header(0), + ID3v2Location(-1), + ID3v2Size(0), + properties(0) {} - ~FilePrivate() - { + ~FilePrivate() { delete ID3v2Header; delete properties; } @@ -87,8 +84,7 @@ public: // static members //////////////////////////////////////////////////////////////////////////////// -bool APE::File::isSupported(IOStream*) -{ +bool APE::File::isSupported(IOStream *) { // An APE file has an ID "MAC " somewhere. An ID3v2 tag may precede. // FIXME: @@ -102,69 +98,58 @@ bool APE::File::isSupported(IOStream*) // public members //////////////////////////////////////////////////////////////////////////////// -APE::File::File(FileName file, bool readProperties, Properties::ReadStyle) : - Strawberry_TagLib::TagLib::File(file), - d(new FilePrivate()) -{ - if(isOpen()) +APE::File::File(FileName file, bool readProperties, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(file), + d(new FilePrivate()) { + if (isOpen()) read(readProperties); } -APE::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) : - Strawberry_TagLib::TagLib::File(stream), - d(new FilePrivate()) -{ - if(isOpen()) +APE::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(stream), + d(new FilePrivate()) { + if (isOpen()) read(readProperties); } -APE::File::~File() -{ +APE::File::~File() { delete d; } -Strawberry_TagLib::TagLib::Tag *APE::File::tag() const -{ +Strawberry_TagLib::TagLib::Tag *APE::File::tag() const { return &d->tag; } -PropertyMap APE::File::properties() const -{ +PropertyMap APE::File::properties() const { return d->tag.properties(); } -void APE::File::removeUnsupportedProperties(const StringList &properties) -{ +void APE::File::removeUnsupportedProperties(const StringList &properties) { d->tag.removeUnsupportedProperties(properties); } -PropertyMap APE::File::setProperties(const PropertyMap &properties) -{ - if(ID3v1Tag()) +PropertyMap APE::File::setProperties(const PropertyMap &properties) { + if (ID3v1Tag()) ID3v1Tag()->setProperties(properties); return APETag(true)->setProperties(properties); } -APE::Properties *APE::File::audioProperties() const -{ +APE::Properties *APE::File::audioProperties() const { return d->properties; } -bool APE::File::save() -{ - if(readOnly()) { +bool APE::File::save() { + if (readOnly()) { debug("APE::File::save() -- File is read only."); return false; } // Update ID3v1 tag - if(ID3v1Tag() && !ID3v1Tag()->isEmpty()) { + if (ID3v1Tag() && !ID3v1Tag()->isEmpty()) { // ID3v1 tag is not empty. Update the old one or create a new one. - if(d->ID3v1Location >= 0) { + if (d->ID3v1Location >= 0) { seek(d->ID3v1Location); } else { @@ -178,7 +163,7 @@ bool APE::File::save() // ID3v1 tag is empty. Remove the old one. - if(d->ID3v1Location >= 0) { + if (d->ID3v1Location >= 0) { truncate(d->ID3v1Location); d->ID3v1Location = -1; } @@ -186,12 +171,12 @@ bool APE::File::save() // Update APE tag - if(APETag() && !APETag()->isEmpty()) { + if (APETag() && !APETag()->isEmpty()) { // APE tag is not empty. Update the old one or create a new one. - if(d->APELocation < 0) { - if(d->ID3v1Location >= 0) + if (d->APELocation < 0) { + if (d->ID3v1Location >= 0) d->APELocation = d->ID3v1Location; else d->APELocation = length(); @@ -200,7 +185,7 @@ bool APE::File::save() const ByteVector data = APETag()->render(); insert(data, d->APELocation, d->APESize); - if(d->ID3v1Location >= 0) + if (d->ID3v1Location >= 0) d->ID3v1Location += (static_cast(data.size()) - d->APESize); d->APESize = data.size(); @@ -209,10 +194,10 @@ bool APE::File::save() // APE tag is empty. Remove the old one. - if(d->APELocation >= 0) { + if (d->APELocation >= 0) { removeBlock(d->APELocation, d->APESize); - if(d->ID3v1Location >= 0) + if (d->ID3v1Location >= 0) d->ID3v1Location -= d->APESize; d->APELocation = -1; @@ -223,35 +208,30 @@ bool APE::File::save() return true; } -ID3v1::Tag *APE::File::ID3v1Tag(bool create) -{ +ID3v1::Tag *APE::File::ID3v1Tag(bool create) { return d->tag.access(ApeID3v1Index, create); } -APE::Tag *APE::File::APETag(bool create) -{ +APE::Tag *APE::File::APETag(bool create) { return d->tag.access(ApeAPEIndex, create); } -void APE::File::strip(int tags) -{ - if(tags & ID3v1) +void APE::File::strip(int tags) { + if (tags & ID3v1) d->tag.set(ApeID3v1Index, 0); - if(tags & APE) + if (tags & APE) d->tag.set(ApeAPEIndex, 0); - if(!ID3v1Tag()) + if (!ID3v1Tag()) APETag(true); } -bool APE::File::hasAPETag() const -{ +bool APE::File::hasAPETag() const { return (d->APELocation >= 0); } -bool APE::File::hasID3v1Tag() const -{ +bool APE::File::hasID3v1Tag() const { return (d->ID3v1Location >= 0); } @@ -259,13 +239,12 @@ bool APE::File::hasID3v1Tag() const // private members //////////////////////////////////////////////////////////////////////////////// -void APE::File::read(bool readProperties) -{ +void APE::File::read(bool readProperties) { // Look for an ID3v2 tag d->ID3v2Location = Utils::findID3v2(this); - if(d->ID3v2Location >= 0) { + if (d->ID3v2Location >= 0) { seek(d->ID3v2Location); d->ID3v2Header = new ID3v2::Header(readBlock(ID3v2::Header::size())); d->ID3v2Size = d->ID3v2Header->completeTagSize(); @@ -275,36 +254,36 @@ void APE::File::read(bool readProperties) d->ID3v1Location = Utils::findID3v1(this); - if(d->ID3v1Location >= 0) + if (d->ID3v1Location >= 0) d->tag.set(ApeID3v1Index, new ID3v1::Tag(this, d->ID3v1Location)); // Look for an APE tag d->APELocation = Utils::findAPE(this, d->ID3v1Location); - if(d->APELocation >= 0) { + if (d->APELocation >= 0) { d->tag.set(ApeAPEIndex, new APE::Tag(this, d->APELocation)); d->APESize = APETag()->footer()->completeTagSize(); d->APELocation = d->APELocation + APE::Footer::size() - d->APESize; } - if(d->ID3v1Location < 0) + if (d->ID3v1Location < 0) APETag(true); // Look for APE audio properties - if(readProperties) { + if (readProperties) { long streamLength; - if(d->APELocation >= 0) + if (d->APELocation >= 0) streamLength = d->APELocation; - else if(d->ID3v1Location >= 0) + else if (d->ID3v1Location >= 0) streamLength = d->ID3v1Location; else streamLength = length(); - if(d->ID3v2Location >= 0) { + if (d->ID3v2Location >= 0) { seek(d->ID3v2Location + d->ID3v2Size); streamLength -= (d->ID3v2Location + d->ID3v2Size); } diff --git a/3rdparty/taglib/ape/apefile.h b/3rdparty/taglib/ape/apefile.h index dc80b5c87..33f5401b6 100644 --- a/3rdparty/taglib/ape/apefile.h +++ b/3rdparty/taglib/ape/apefile.h @@ -41,59 +41,62 @@ namespace Strawberry_TagLib { namespace TagLib { - class Tag; +class Tag; - namespace ID3v1 { class Tag; } - namespace APE { class Tag; } +namespace ID3v1 { +class Tag; +} +namespace APE { +class Tag; +} - //! An implementation of APE metadata +//! An implementation of APE metadata - /*! +/*! * This is implementation of APE metadata. * * This supports ID3v1 and APE (v1 and v2) style comments as well as reading stream * properties from the file. */ - namespace APE { +namespace APE { - //! An implementation of TagLib::File with APE specific methods +//! An implementation of TagLib::File with APE specific methods - /*! +/*! * This implements and provides an interface for APE files to the * TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing * the abstract TagLib::File API as well as providing some additional * information specific to APE files. */ - class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File - { - public: - /*! +class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File { + public: + /*! * This set of flags is used for various operations and is suitable for * being OR-ed together. */ - enum TagTypes { - //! Empty set. Matches no tag types. - NoTags = 0x0000, - //! Matches ID3v1 tags. - ID3v1 = 0x0001, - //! Matches APE tags. - APE = 0x0002, - //! Matches all tag types. - AllTags = 0xffff - }; + enum TagTypes { + //! Empty set. Matches no tag types. + NoTags = 0x0000, + //! Matches ID3v1 tags. + ID3v1 = 0x0001, + //! Matches APE tags. + APE = 0x0002, + //! Matches all tag types. + AllTags = 0xffff + }; - /*! + /*! * Constructs an APE file from \a file. If \a readProperties is true the * file's audio properties will also be read. * * \note In the current implementation, \a propertiesStyle is ignored. */ - File(FileName file, bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(FileName file, bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Constructs an APE file from \a stream. If \a readProperties is true the * file's audio properties will also be read. * @@ -102,55 +105,55 @@ namespace TagLib { * * \note In the current implementation, \a propertiesStyle is ignored. */ - File(IOStream *stream, bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(IOStream *stream, bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Destroys this instance of the File. */ - virtual ~File(); + virtual ~File(); - /*! + /*! * Returns the Tag for this file. This will be an APE tag, an ID3v1 tag * or a combination of the two. */ - virtual Strawberry_TagLib::TagLib::Tag *tag() const; + virtual Strawberry_TagLib::TagLib::Tag *tag() const; - /*! + /*! * Implements the unified property interface -- export function. * If the file contains both an APE and an ID3v1 tag, only APE * will be converted to the PropertyMap. */ - PropertyMap properties() const; + PropertyMap properties() const; - /*! + /*! * Removes unsupported properties. Forwards to the actual Tag's * removeUnsupportedProperties() function. */ - void removeUnsupportedProperties(const StringList &properties); + void removeUnsupportedProperties(const StringList &properties); - /*! + /*! * Implements the unified property interface -- import function. * Creates an APEv2 tag if necessary. A potentially existing ID3v1 * tag will be updated as well. */ - PropertyMap setProperties(const PropertyMap &); + PropertyMap setProperties(const PropertyMap &); - /*! + /*! * Returns the APE::Properties for this file. If no audio properties * were read then this will return a null pointer. */ - virtual Properties *audioProperties() const; + virtual Properties *audioProperties() const; - /*! + /*! * Saves the file. * * \note According to the official Monkey's Audio SDK, an APE file * can only have either ID3V1 or APE tags, so a parameter is used here. */ - virtual bool save(); + virtual bool save(); - /*! + /*! * Returns a pointer to the ID3v1 tag of the file. * * If \a create is false (the default) this may return a null pointer @@ -167,9 +170,9 @@ namespace TagLib { * * \see hasID3v1Tag() */ - ID3v1::Tag *ID3v1Tag(bool create = false); + ID3v1::Tag *ID3v1Tag(bool create = false); - /*! + /*! * Returns a pointer to the APE tag of the file. * * If \a create is false (the default) this may return a null pointer @@ -186,9 +189,9 @@ namespace TagLib { * * \see hasAPETag() */ - APE::Tag *APETag(bool create = false); + APE::Tag *APETag(bool create = false); - /*! + /*! * This will remove the tags that match the OR-ed together TagTypes from the * file. By default it removes all tags. * @@ -196,42 +199,42 @@ namespace TagLib { * as their memory will be freed. * \note In order to make the removal permanent save() still needs to be called */ - void strip(int tags = AllTags); + void strip(int tags = AllTags); - /*! + /*! * Returns whether or not the file on disk actually has an APE tag. * * \see APETag() */ - bool hasAPETag() const; + bool hasAPETag() const; - /*! + /*! * Returns whether or not the file on disk actually has an ID3v1 tag. * * \see ID3v1Tag() */ - bool hasID3v1Tag() const; + bool hasID3v1Tag() const; - /*! + /*! * Returns whether or not the given \a stream can be opened as an APE * file. * * \note This method is designed to do a quick check. The result may * not necessarily be correct. */ - static bool isSupported(IOStream *stream); + static bool isSupported(IOStream *stream); - private: - File(const File &); - File &operator=(const File &); + private: + File(const File &); + File &operator=(const File &); - void read(bool readProperties); + void read(bool readProperties); - class FilePrivate; - FilePrivate *d; - }; - } -} -} + class FilePrivate; + FilePrivate *d; +}; +} // namespace APE +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/ape/apefooter.cpp b/3rdparty/taglib/ape/apefooter.cpp index 62104abac..356f31db4 100644 --- a/3rdparty/taglib/ape/apefooter.cpp +++ b/3rdparty/taglib/ape/apefooter.cpp @@ -35,16 +35,14 @@ using namespace Strawberry_TagLib::TagLib; using namespace APE; -class APE::Footer::FooterPrivate -{ -public: - FooterPrivate() : - version(0), - footerPresent(true), - headerPresent(false), - isHeader(false), - itemCount(0), - tagSize(0) {} +class APE::Footer::FooterPrivate { + public: + FooterPrivate() : version(0), + footerPresent(true), + headerPresent(false), + isHeader(false), + itemCount(0), + tagSize(0) {} unsigned int version; @@ -61,13 +59,11 @@ public: // static members //////////////////////////////////////////////////////////////////////////////// -unsigned int APE::Footer::size() -{ +unsigned int APE::Footer::size() { return 32; } -ByteVector APE::Footer::fileIdentifier() -{ +ByteVector APE::Footer::fileIdentifier() { return ByteVector("APETAGEX"); } @@ -75,88 +71,70 @@ ByteVector APE::Footer::fileIdentifier() // public members //////////////////////////////////////////////////////////////////////////////// -APE::Footer::Footer() : - d(new FooterPrivate()) -{ +APE::Footer::Footer() : d(new FooterPrivate()) { } -APE::Footer::Footer(const ByteVector &data) : - d(new FooterPrivate()) -{ +APE::Footer::Footer(const ByteVector &data) : d(new FooterPrivate()) { parse(data); } -APE::Footer::~Footer() -{ +APE::Footer::~Footer() { delete d; } -unsigned int APE::Footer::version() const -{ +unsigned int APE::Footer::version() const { return d->version; } -bool APE::Footer::headerPresent() const -{ +bool APE::Footer::headerPresent() const { return d->headerPresent; } -bool APE::Footer::footerPresent() const -{ +bool APE::Footer::footerPresent() const { return d->footerPresent; } -bool APE::Footer::isHeader() const -{ +bool APE::Footer::isHeader() const { return d->isHeader; } -void APE::Footer::setHeaderPresent(bool b) const -{ +void APE::Footer::setHeaderPresent(bool b) const { d->headerPresent = b; } -unsigned int APE::Footer::itemCount() const -{ +unsigned int APE::Footer::itemCount() const { return d->itemCount; } -void APE::Footer::setItemCount(unsigned int s) -{ +void APE::Footer::setItemCount(unsigned int s) { d->itemCount = s; } -unsigned int APE::Footer::tagSize() const -{ +unsigned int APE::Footer::tagSize() const { return d->tagSize; } -unsigned int APE::Footer::completeTagSize() const -{ - if(d->headerPresent) +unsigned int APE::Footer::completeTagSize() const { + if (d->headerPresent) return d->tagSize + size(); else return d->tagSize; } -void APE::Footer::setTagSize(unsigned int s) -{ +void APE::Footer::setTagSize(unsigned int s) { d->tagSize = s; } -void APE::Footer::setData(const ByteVector &data) -{ +void APE::Footer::setData(const ByteVector &data) { parse(data); } -ByteVector APE::Footer::renderFooter() const -{ +ByteVector APE::Footer::renderFooter() const { return render(false); } -ByteVector APE::Footer::renderHeader() const -{ - if(!d->headerPresent) +ByteVector APE::Footer::renderHeader() const { + if (!d->headerPresent) return ByteVector(); else return render(true); @@ -166,9 +144,8 @@ ByteVector APE::Footer::renderHeader() const // protected members //////////////////////////////////////////////////////////////////////////////// -void APE::Footer::parse(const ByteVector &data) -{ - if(data.size() < size()) +void APE::Footer::parse(const ByteVector &data) { + if (data.size() < size()) return; // The first eight bytes, data[0..7], are the File Identifier, "APETAGEX". @@ -192,11 +169,9 @@ void APE::Footer::parse(const ByteVector &data) d->headerPresent = flags[31]; d->footerPresent = !flags[30]; d->isHeader = flags[29]; - } -ByteVector APE::Footer::render(bool isHeader) const -{ +ByteVector APE::Footer::render(bool isHeader) const { ByteVector v; // add the file identifier -- "APETAGEX" @@ -221,7 +196,7 @@ ByteVector APE::Footer::render(bool isHeader) const std::bitset<32> flags; flags[31] = d->headerPresent; - flags[30] = false; // footer is always present + flags[30] = false; // footer is always present flags[29] = isHeader; v.append(ByteVector::fromUInt(flags.to_ulong(), false)); diff --git a/3rdparty/taglib/ape/apefooter.h b/3rdparty/taglib/ape/apefooter.h index 4f91d1e90..ed3a1cab7 100644 --- a/3rdparty/taglib/ape/apefooter.h +++ b/3rdparty/taglib/ape/apefooter.h @@ -32,144 +32,143 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace APE { +namespace APE { - //! An implementation of APE footers +//! An implementation of APE footers - /*! +/*! * This class implements APE footers (and headers). It attempts to follow, both * semantically and programmatically, the structure specified in * the APE v2.0 standard. The API is based on the properties of APE footer and * headers specified there. */ - class TAGLIB_EXPORT Footer - { - public: - /*! +class TAGLIB_EXPORT Footer { + public: + /*! * Constructs an empty APE footer. */ - Footer(); + Footer(); - /*! + /*! * Constructs an APE footer based on \a data. parse() is called * immediately. */ - Footer(const ByteVector &data); + Footer(const ByteVector &data); - /*! + /*! * Destroys the footer. */ - virtual ~Footer(); + virtual ~Footer(); - /*! + /*! * Returns the version number. (Note: This is the 1000 or 2000.) */ - unsigned int version() const; + unsigned int version() const; - /*! + /*! * Returns true if a header is present in the tag. */ - bool headerPresent() const; + bool headerPresent() const; - /*! + /*! * Returns true if a footer is present in the tag. */ - bool footerPresent() const; + bool footerPresent() const; - /*! + /*! * Returns true this is actually the header. */ - bool isHeader() const; + bool isHeader() const; - /*! + /*! * Sets whether the header should be rendered or not */ - void setHeaderPresent(bool b) const; + void setHeaderPresent(bool b) const; - /*! + /*! * Returns the number of items in the tag. */ - unsigned int itemCount() const; + unsigned int itemCount() const; - /*! + /*! * Set the item count to \a s. * \see itemCount() */ - void setItemCount(unsigned int s); + void setItemCount(unsigned int s); - /*! + /*! * Returns the tag size in bytes. This is the size of the frame content and footer. * The size of the \e entire tag will be this plus the header size, if present. * * \see completeTagSize() */ - unsigned int tagSize() const; + unsigned int tagSize() const; - /*! + /*! * Returns the tag size, including if present, the header * size. * * \see tagSize() */ - unsigned int completeTagSize() const; + unsigned int completeTagSize() const; - /*! + /*! * Set the tag size to \a s. * \see tagSize() */ - void setTagSize(unsigned int s); + void setTagSize(unsigned int s); - /*! + /*! * Returns the size of the footer. Presently this is always 32 bytes. */ - static unsigned int size(); + static unsigned int size(); - /*! + /*! * Returns the string used to identify an APE tag inside of a file. * Presently this is always "APETAGEX". */ - static ByteVector fileIdentifier(); + static ByteVector fileIdentifier(); - /*! + /*! * Sets the data that will be used as the footer. 32 bytes, * starting from \a data will be used. */ - void setData(const ByteVector &data); + void setData(const ByteVector &data); - /*! + /*! * Renders the footer back to binary format. */ - ByteVector renderFooter() const; + ByteVector renderFooter() const; - /*! + /*! * Renders the header corresponding to the footer. If headerPresent is * set to false, it returns an empty ByteVector. */ - ByteVector renderHeader() const; + ByteVector renderHeader() const; - protected: - /*! + protected: + /*! * Called by setData() to parse the footer data. It makes this information * available through the public API. */ - void parse(const ByteVector &data); + void parse(const ByteVector &data); - /*! + /*! * Called by renderFooter and renderHeader */ - ByteVector render(bool isHeader) const; + ByteVector render(bool isHeader) const; - private: - Footer(const Footer &); - Footer &operator=(const Footer &); + private: + Footer(const Footer &); + Footer &operator=(const Footer &); - class FooterPrivate; - FooterPrivate *d; - }; + class FooterPrivate; + FooterPrivate *d; +}; - } -} -} +} // namespace APE +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/ape/apeitem.cpp b/3rdparty/taglib/ape/apeitem.cpp index 5f41ca932..5799470fa 100644 --- a/3rdparty/taglib/ape/apeitem.cpp +++ b/3rdparty/taglib/ape/apeitem.cpp @@ -31,12 +31,10 @@ using namespace Strawberry_TagLib::TagLib; using namespace APE; -class APE::Item::ItemPrivate -{ -public: - ItemPrivate() : - type(Text), - readOnly(false) {} +class APE::Item::ItemPrivate { + public: + ItemPrivate() : type(Text), + readOnly(false) {} Item::ItemTypes type; String key; @@ -49,30 +47,22 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -APE::Item::Item() : - d(new ItemPrivate()) -{ +APE::Item::Item() : d(new ItemPrivate()) { } -APE::Item::Item(const String &key, const String &value) : - d(new ItemPrivate()) -{ +APE::Item::Item(const String &key, const String &value) : d(new ItemPrivate()) { d->key = key; d->text.append(value); } -APE::Item::Item(const String &key, const StringList &values) : - d(new ItemPrivate()) -{ +APE::Item::Item(const String &key, const StringList &values) : d(new ItemPrivate()) { d->key = key; d->text = values; } -APE::Item::Item(const String &key, const ByteVector &value, bool binary) : - d(new ItemPrivate()) -{ +APE::Item::Item(const String &key, const ByteVector &value, bool binary) : d(new ItemPrivate()) { d->key = key; - if(binary) { + if (binary) { d->type = Binary; d->value = value; } @@ -81,118 +71,99 @@ APE::Item::Item(const String &key, const ByteVector &value, bool binary) : } } -APE::Item::Item(const Item &item) : - d(new ItemPrivate(*item.d)) -{ +APE::Item::Item(const Item &item) : d(new ItemPrivate(*item.d)) { } -APE::Item::~Item() -{ +APE::Item::~Item() { delete d; } -Item &APE::Item::operator=(const Item &item) -{ +Item &APE::Item::operator=(const Item &item) { Item(item).swap(*this); return *this; } -void APE::Item::swap(Item &item) -{ +void APE::Item::swap(Item &item) { using std::swap; swap(d, item.d); } -void APE::Item::setReadOnly(bool readOnly) -{ +void APE::Item::setReadOnly(bool readOnly) { d->readOnly = readOnly; } -bool APE::Item::isReadOnly() const -{ +bool APE::Item::isReadOnly() const { return d->readOnly; } -void APE::Item::setType(APE::Item::ItemTypes val) -{ +void APE::Item::setType(APE::Item::ItemTypes val) { d->type = val; } -APE::Item::ItemTypes APE::Item::type() const -{ +APE::Item::ItemTypes APE::Item::type() const { return d->type; } -String APE::Item::key() const -{ +String APE::Item::key() const { return d->key; } -ByteVector APE::Item::binaryData() const -{ +ByteVector APE::Item::binaryData() const { return d->value; } -void APE::Item::setBinaryData(const ByteVector &value) -{ +void APE::Item::setBinaryData(const ByteVector &value) { d->type = Binary; d->value = value; d->text.clear(); } -ByteVector APE::Item::value() const -{ +ByteVector APE::Item::value() const { // This seems incorrect as it won't be actually rendering the value to keep it // up to date. return d->value; } -void APE::Item::setKey(const String &key) -{ +void APE::Item::setKey(const String &key) { d->key = key; } -void APE::Item::setValue(const String &value) -{ +void APE::Item::setValue(const String &value) { d->type = Text; d->text = value; d->value.clear(); } -void APE::Item::setValues(const StringList &value) -{ +void APE::Item::setValues(const StringList &value) { d->type = Text; d->text = value; d->value.clear(); } -void APE::Item::appendValue(const String &value) -{ +void APE::Item::appendValue(const String &value) { d->type = Text; d->text.append(value); d->value.clear(); } -void APE::Item::appendValues(const StringList &values) -{ +void APE::Item::appendValues(const StringList &values) { d->type = Text; d->text.append(values); d->value.clear(); } -int APE::Item::size() const -{ +int APE::Item::size() const { int result = 8 + d->key.size() + 1; - switch(d->type) { + switch (d->type) { case Text: - if(!d->text.isEmpty()) { + if (!d->text.isEmpty()) { StringList::ConstIterator it = d->text.begin(); result += it->data(String::UTF8).size(); it++; - for(; it != d->text.end(); ++it) + for (; it != d->text.end(); ++it) result += 1 + it->data(String::UTF8).size(); } break; @@ -205,31 +176,27 @@ int APE::Item::size() const return result; } -StringList APE::Item::toStringList() const -{ +StringList APE::Item::toStringList() const { return d->text; } -StringList APE::Item::values() const -{ +StringList APE::Item::values() const { return d->text; } -String APE::Item::toString() const -{ - if(d->type == Text && !isEmpty()) +String APE::Item::toString() const { + if (d->type == Text && !isEmpty()) return d->text.front(); else return String(); } -bool APE::Item::isEmpty() const -{ - switch(d->type) { +bool APE::Item::isEmpty() const { + switch (d->type) { case Text: - if(d->text.isEmpty()) + if (d->text.isEmpty()) return true; - if(d->text.size() == 1 && d->text.front().isEmpty()) + if (d->text.size() == 1 && d->text.front().isEmpty()) return true; return false; case Binary: @@ -240,17 +207,16 @@ bool APE::Item::isEmpty() const } } -void APE::Item::parse(const ByteVector &data) -{ +void APE::Item::parse(const ByteVector &data) { // 11 bytes is the minimum size for an APE item - if(data.size() < 11) { + if (data.size() < 11) { debug("APE::Item::parse() -- no data in item"); return; } - const unsigned int valueLength = data.toUInt(0, false); - const unsigned int flags = data.toUInt(4, false); + const unsigned int valueLength = data.toUInt(0, false); + const unsigned int flags = data.toUInt(4, false); // An item key can contain ASCII characters from 0x20 up to 0x7E, not UTF-8. // We assume that the validity of the given key has been checked. @@ -262,27 +228,26 @@ void APE::Item::parse(const ByteVector &data) setReadOnly(flags & 1); setType(ItemTypes((flags >> 1) & 3)); - if(Text == d->type) + if (Text == d->type) d->text = StringList(ByteVectorList::split(value, '\0'), String::UTF8); else d->value = value; } -ByteVector APE::Item::render() const -{ +ByteVector APE::Item::render() const { ByteVector data; unsigned int flags = ((d->readOnly) ? 1 : 0) | (d->type << 1); ByteVector value; - if(isEmpty()) + if (isEmpty()) return data; - if(d->type == Text) { + if (d->type == Text) { StringList::ConstIterator it = d->text.begin(); value.append(it->data(String::UTF8)); it++; - for(; it != d->text.end(); ++it) { + for (; it != d->text.end(); ++it) { value.append('\0'); value.append(it->data(String::UTF8)); } diff --git a/3rdparty/taglib/ape/apeitem.h b/3rdparty/taglib/ape/apeitem.h index c3f6acb8f..f5e7fd2d1 100644 --- a/3rdparty/taglib/ape/apeitem.h +++ b/3rdparty/taglib/ape/apeitem.h @@ -33,194 +33,191 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace APE { +namespace APE { - //! An implementation of APE-items +//! An implementation of APE-items - /*! +/*! * This class provides the features of items in the APEv2 standard. */ - class TAGLIB_EXPORT Item - { - public: - /*! +class TAGLIB_EXPORT Item { + public: + /*! * Enum of types an Item can have. The value of 3 is reserved. */ - enum ItemTypes { - //! Item contains text information coded in UTF-8 - Text = 0, - //! Item contains binary information - Binary = 1, - //! Item is a locator of external stored information - Locator = 2 - }; - /*! + enum ItemTypes { + //! Item contains text information coded in UTF-8 + Text = 0, + //! Item contains binary information + Binary = 1, + //! Item is a locator of external stored information + Locator = 2 + }; + /*! * Constructs an empty item. */ - Item(); + Item(); - /*! + /*! * Constructs a text item with \a key and \a value. */ - // BIC: Remove this, StringList has a constructor from a single string - Item(const String &key, const String &value); + // BIC: Remove this, StringList has a constructor from a single string + Item(const String &key, const String &value); - /*! + /*! * Constructs a text item with \a key and \a values. */ - Item(const String &key, const StringList &values); + Item(const String &key, const StringList &values); - /*! + /*! * Constructs an item with \a key and \a value. * If \a binary is true a Binary item will be created, otherwise \a value will be interpreted as text */ - Item(const String &key, const ByteVector &value, bool binary); + Item(const String &key, const ByteVector &value, bool binary); - /*! + /*! * Construct an item as a copy of \a item. */ - Item(const Item &item); + Item(const Item &item); - /*! + /*! * Destroys the item. */ - virtual ~Item(); + virtual ~Item(); - /*! + /*! * Copies the contents of \a item into this item. */ - Item &operator=(const Item &item); + Item &operator=(const Item &item); - /*! + /*! * Exchanges the content of this item by the content of \a item. */ - void swap(Item &item); + void swap(Item &item); - /*! + /*! * Returns the key. */ - String key() const; + String key() const; - /*! + /*! * Returns the binary value. * If the item type is not \a Binary, always returns an empty ByteVector. */ - ByteVector binaryData() const; + ByteVector binaryData() const; - /*! + /*! * Set the binary value to \a value * The item's type will also be set to \a Binary */ - void setBinaryData(const ByteVector &value); + void setBinaryData(const ByteVector &value); #ifndef DO_NOT_DOCUMENT - /* Remove in next binary incompatible release */ - ByteVector value() const; + /* Remove in next binary incompatible release */ + ByteVector value() const; #endif - /*! + /*! * Sets the key for the item to \a key. */ - void setKey(const String &key); + void setKey(const String &key); - /*! + /*! * Sets the text value of the item to \a value and clears any previous contents. * * \see toString() */ - void setValue(const String &value); + void setValue(const String &value); - /*! + /*! * Sets the text value of the item to the list of values in \a value and clears * any previous contents. * * \see toStringList() */ - void setValues(const StringList &values); + void setValues(const StringList &values); - /*! + /*! * Appends \a value to create (or extend) the current list of text values. * * \see toString() */ - void appendValue(const String &value); + void appendValue(const String &value); - /*! + /*! * Appends \a values to extend the current list of text values. * * \see toStringList() */ - void appendValues(const StringList &values); + void appendValues(const StringList &values); - /*! + /*! * Returns the size of the full item. */ - int size() const; + int size() const; - /*! + /*! * Returns the value as a single string. In case of multiple strings, * the first is returned. If the data type is not \a Text, always returns * an empty String. */ - String toString() const; + String toString() const; #ifndef DO_NOT_DOCUMENT - /* Remove in next binary incompatible release */ - StringList toStringList() const; + /* Remove in next binary incompatible release */ + StringList toStringList() const; #endif - /*! + /*! * Returns the list of text values. If the data type is not \a Text, always * returns an empty StringList. */ - StringList values() const; + StringList values() const; - /*! + /*! * Render the item to a ByteVector. */ - ByteVector render() const; + ByteVector render() const; - /*! + /*! * Parse the item from the ByteVector \a data. */ - void parse(const ByteVector& data); + void parse(const ByteVector &data); - /*! + /*! * Set the item to read-only. */ - void setReadOnly(bool readOnly); + void setReadOnly(bool readOnly); - /*! + /*! * Return true if the item is read-only. */ - bool isReadOnly() const; + bool isReadOnly() const; - /*! + /*! * Sets the type of the item to \a type. * * \see ItemTypes */ - void setType(ItemTypes type); + void setType(ItemTypes type); - /*! + /*! * Returns the type of the item. */ - ItemTypes type() const; + ItemTypes type() const; - /*! + /*! * Returns if the item has any real content. */ - bool isEmpty() const; + bool isEmpty() const; - private: - class ItemPrivate; - ItemPrivate *d; - }; - } + private: + class ItemPrivate; + ItemPrivate *d; +}; +} // namespace APE -} -} +} // namespace TagLib +} // namespace Strawberry_TagLib #endif - - diff --git a/3rdparty/taglib/ape/apeproperties.cpp b/3rdparty/taglib/ape/apeproperties.cpp index 3744727ec..28bc2cf4f 100644 --- a/3rdparty/taglib/ape/apeproperties.cpp +++ b/3rdparty/taglib/ape/apeproperties.cpp @@ -38,17 +38,15 @@ using namespace Strawberry_TagLib::TagLib; -class APE::Properties::PropertiesPrivate -{ -public: - PropertiesPrivate() : - length(0), - bitrate(0), - sampleRate(0), - channels(0), - version(0), - bitsPerSample(0), - sampleFrames(0) {} +class APE::Properties::PropertiesPrivate { + public: + PropertiesPrivate() : length(0), + bitrate(0), + sampleRate(0), + channels(0), + version(0), + bitsPerSample(0), + sampleFrames(0) {} int length; int bitrate; @@ -63,67 +61,53 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -APE::Properties::Properties(File *, ReadStyle style) : - AudioProperties(style), - d(new PropertiesPrivate()) -{ +APE::Properties::Properties(File *, ReadStyle style) : AudioProperties(style), + d(new PropertiesPrivate()) { debug("APE::Properties::Properties() -- This constructor is no longer used."); } -APE::Properties::Properties(File *file, long streamLength, ReadStyle style) : - AudioProperties(style), - d(new PropertiesPrivate()) -{ +APE::Properties::Properties(File *file, long streamLength, ReadStyle style) : AudioProperties(style), + d(new PropertiesPrivate()) { read(file, streamLength); } -APE::Properties::~Properties() -{ +APE::Properties::~Properties() { delete d; } -int APE::Properties::length() const -{ +int APE::Properties::length() const { return lengthInSeconds(); } -int APE::Properties::lengthInSeconds() const -{ +int APE::Properties::lengthInSeconds() const { return d->length / 1000; } -int APE::Properties::lengthInMilliseconds() const -{ +int APE::Properties::lengthInMilliseconds() const { return d->length; } -int APE::Properties::bitrate() const -{ +int APE::Properties::bitrate() const { return d->bitrate; } -int APE::Properties::sampleRate() const -{ +int APE::Properties::sampleRate() const { return d->sampleRate; } -int APE::Properties::channels() const -{ +int APE::Properties::channels() const { return d->channels; } -int APE::Properties::version() const -{ +int APE::Properties::version() const { return d->version; } -int APE::Properties::bitsPerSample() const -{ +int APE::Properties::bitsPerSample() const { return d->bitsPerSample; } -unsigned int APE::Properties::sampleFrames() const -{ +unsigned int APE::Properties::sampleFrames() const { return d->sampleFrames; } @@ -131,89 +115,84 @@ unsigned int APE::Properties::sampleFrames() const // private members //////////////////////////////////////////////////////////////////////////////// -namespace -{ - int headerVersion(const ByteVector &header) - { - if(header.size() < 6 || !header.startsWith("MAC ")) - return -1; +namespace { +int headerVersion(const ByteVector &header) { + if (header.size() < 6 || !header.startsWith("MAC ")) + return -1; - return header.toUShort(4, false); - } + return header.toUShort(4, false); } +} // namespace -void APE::Properties::read(File *file, long streamLength) -{ +void APE::Properties::read(File *file, long streamLength) { // First, we assume that the file pointer is set at the first descriptor. long offset = file->tell(); int version = headerVersion(file->readBlock(6)); // Next, we look for the descriptor. - if(version < 0) { + if (version < 0) { offset = file->find("MAC ", offset); file->seek(offset); version = headerVersion(file->readBlock(6)); } - if(version < 0) { + if (version < 0) { debug("APE::Properties::read() -- APE descriptor not found"); return; } d->version = version; - if(d->version >= 3980) + if (d->version >= 3980) analyzeCurrent(file); else analyzeOld(file); - if(d->sampleFrames > 0 && d->sampleRate > 0) { + if (d->sampleFrames > 0 && d->sampleRate > 0) { const double length = d->sampleFrames * 1000.0 / d->sampleRate; - d->length = static_cast(length + 0.5); + d->length = static_cast(length + 0.5); d->bitrate = static_cast(streamLength * 8.0 / length + 0.5); } } -void APE::Properties::analyzeCurrent(File *file) -{ +void APE::Properties::analyzeCurrent(File *file) { // Read the descriptor file->seek(2, File::Current); const ByteVector descriptor = file->readBlock(44); - if(descriptor.size() < 44) { + if (descriptor.size() < 44) { debug("APE::Properties::analyzeCurrent() -- descriptor is too short."); return; } const unsigned int descriptorBytes = descriptor.toUInt(0, false); - if((descriptorBytes - 52) > 0) + if ((descriptorBytes - 52) > 0) file->seek(descriptorBytes - 52, File::Current); // Read the header const ByteVector header = file->readBlock(24); - if(header.size() < 24) { + if (header.size() < 24) { debug("APE::Properties::analyzeCurrent() -- MAC header is too short."); return; } // Get the APE info - d->channels = header.toShort(18, false); - d->sampleRate = header.toUInt(20, false); + d->channels = header.toShort(18, false); + d->sampleRate = header.toUInt(20, false); d->bitsPerSample = header.toShort(16, false); const unsigned int totalFrames = header.toUInt(12, false); - if(totalFrames == 0) + if (totalFrames == 0) return; - const unsigned int blocksPerFrame = header.toUInt(4, false); + const unsigned int blocksPerFrame = header.toUInt(4, false); const unsigned int finalFrameBlocks = header.toUInt(8, false); d->sampleFrames = (totalFrames - 1) * blocksPerFrame + finalFrameBlocks; } -void APE::Properties::analyzeOld(File *file) -{ +void APE::Properties::analyzeOld(File *file) { const ByteVector header = file->readBlock(26); - if(header.size() < 26) { + if (header.size() < 26) { debug("APE::Properties::analyzeOld() -- MAC header is too short."); return; } @@ -221,20 +200,20 @@ void APE::Properties::analyzeOld(File *file) const unsigned int totalFrames = header.toUInt(18, false); // Fail on 0 length APE files (catches non-finalized APE files) - if(totalFrames == 0) + if (totalFrames == 0) return; const short compressionLevel = header.toShort(0, false); unsigned int blocksPerFrame; - if(d->version >= 3950) + if (d->version >= 3950) blocksPerFrame = 73728 * 4; - else if(d->version >= 3900 || (d->version >= 3800 && compressionLevel == 4000)) + else if (d->version >= 3900 || (d->version >= 3800 && compressionLevel == 4000)) blocksPerFrame = 73728; else blocksPerFrame = 9216; // Get the APE info - d->channels = header.toShort(4, false); + d->channels = header.toShort(4, false); d->sampleRate = header.toUInt(6, false); const unsigned int finalFrameBlocks = header.toUInt(22, false); @@ -243,7 +222,7 @@ void APE::Properties::analyzeOld(File *file) // Get the bit depth from the RIFF-fmt chunk. file->seek(16, File::Current); const ByteVector fmt = file->readBlock(28); - if(fmt.size() < 28 || !fmt.startsWith("WAVEfmt ")) { + if (fmt.size() < 28 || !fmt.startsWith("WAVEfmt ")) { debug("APE::Properties::analyzeOld() -- fmt header is too short."); return; } diff --git a/3rdparty/taglib/ape/apeproperties.h b/3rdparty/taglib/ape/apeproperties.h index 710240c37..71dc416ca 100644 --- a/3rdparty/taglib/ape/apeproperties.h +++ b/3rdparty/taglib/ape/apeproperties.h @@ -36,40 +36,39 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace APE { +namespace APE { - class File; +class File; - //! An implementation of audio property reading for APE +//! An implementation of audio property reading for APE - /*! +/*! * This reads the data from an APE stream found in the AudioProperties * API. */ - class TAGLIB_EXPORT Properties : public AudioProperties - { - public: - /*! +class TAGLIB_EXPORT Properties : public AudioProperties { + public: + /*! * Create an instance of APE::Properties with the data read from the * APE::File \a file. * * \deprecated */ - TAGLIB_DEPRECATED Properties(File *file, ReadStyle style = Average); + TAGLIB_DEPRECATED Properties(File *file, ReadStyle style = Average); - /*! + /*! * Create an instance of APE::Properties with the data read from the * APE::File \a file. */ - Properties(File *file, long streamLength, ReadStyle style = Average); + Properties(File *file, long streamLength, ReadStyle style = Average); - /*! + /*! * Destroys this APE::Properties instance. */ - virtual ~Properties(); + virtual ~Properties(); - /*! + /*! * Returns the length of the file in seconds. The length is rounded down to * the nearest whole second. * @@ -77,69 +76,69 @@ namespace TagLib { * * \deprecated */ - TAGLIB_DEPRECATED virtual int length() const; + TAGLIB_DEPRECATED virtual int length() const; - /*! + /*! * Returns the length of the file in seconds. The length is rounded down to * the nearest whole second. * * \see lengthInMilliseconds() */ - // BIC: make virtual - int lengthInSeconds() const; + // BIC: make virtual + int lengthInSeconds() const; - /*! + /*! * Returns the length of the file in milliseconds. * * \see lengthInSeconds() */ - // BIC: make virtual - int lengthInMilliseconds() const; + // BIC: make virtual + int lengthInMilliseconds() const; - /*! + /*! * Returns the average bit rate of the file in kb/s. */ - virtual int bitrate() const; + virtual int bitrate() const; - /*! + /*! * Returns the sample rate in Hz. */ - virtual int sampleRate() const; + virtual int sampleRate() const; - /*! + /*! * Returns the number of audio channels. */ - virtual int channels() const; + virtual int channels() const; - /*! + /*! * Returns the number of bits per audio sample. */ - int bitsPerSample() const; + int bitsPerSample() const; - /*! + /*! * Returns the total number of audio samples in file. */ - unsigned int sampleFrames() const; + unsigned int sampleFrames() const; - /*! + /*! * Returns APE version. */ - int version() const; + int version() const; - private: - Properties(const Properties &); - Properties &operator=(const Properties &); + private: + Properties(const Properties &); + Properties &operator=(const Properties &); - void read(File *file, long streamLength); + void read(File *file, long streamLength); - void analyzeCurrent(File *file); - void analyzeOld(File *file); + void analyzeCurrent(File *file); + void analyzeOld(File *file); - class PropertiesPrivate; - PropertiesPrivate *d; - }; - } -} -} + class PropertiesPrivate; + PropertiesPrivate *d; +}; +} // namespace APE +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/ape/apetag.cpp b/3rdparty/taglib/ape/apetag.cpp index 66d81e11b..f74db48dd 100644 --- a/3rdparty/taglib/ape/apetag.cpp +++ b/3rdparty/taglib/ape/apetag.cpp @@ -28,7 +28,7 @@ // it considers specializations with and without class types // to be different; this define forces Map to use only the // specialization with the class keyword. -#define WANT_CLASS_INSTANTIATION_OF_MAP (1) +# define WANT_CLASS_INSTANTIATION_OF_MAP (1) #endif #include @@ -45,39 +45,35 @@ using namespace Strawberry_TagLib::TagLib; using namespace APE; -namespace -{ - const unsigned int MinKeyLength = 2; - const unsigned int MaxKeyLength = 255; +namespace { +const unsigned int MinKeyLength = 2; +const unsigned int MaxKeyLength = 255; - bool isKeyValid(const ByteVector &key) - { - const char *invalidKeys[] = { "ID3", "TAG", "OGGS", "MP+", 0 }; +bool isKeyValid(const ByteVector &key) { - // only allow printable ASCII including space (32..126) + const char *invalidKeys[] = { "ID3", "TAG", "OGGS", "MP+", 0 }; - for(ByteVector::ConstIterator it = key.begin(); it != key.end(); ++it) { - const int c = static_cast(*it); - if(c < 32 || c > 126) - return false; - } + // only allow printable ASCII including space (32..126) - const String upperKey = String(key).upper(); - for(size_t i = 0; invalidKeys[i] != 0; ++i) { - if(upperKey == invalidKeys[i]) - return false; - } - - return true; + for (ByteVector::ConstIterator it = key.begin(); it != key.end(); ++it) { + const int c = static_cast(*it); + if (c < 32 || c > 126) + return false; } -} -class APE::Tag::TagPrivate -{ -public: - TagPrivate() : - file(0), - footerLocation(0) {} + const String upperKey = String(key).upper(); + for (size_t i = 0; invalidKeys[i] != 0; ++i) { + if (upperKey == invalidKeys[i]) + return false; + } + + return true; +} +} // namespace + +class APE::Tag::TagPrivate { + public: + TagPrivate() : file(0), footerLocation(0) {} File *file; long footerLocation; @@ -90,150 +86,140 @@ public: // public methods //////////////////////////////////////////////////////////////////////////////// -APE::Tag::Tag() : - Strawberry_TagLib::TagLib::Tag(), - d(new TagPrivate()) -{ -} +APE::Tag::Tag() : Strawberry_TagLib::TagLib::Tag(), d(new TagPrivate()) {} + +APE::Tag::Tag(Strawberry_TagLib::TagLib::File *file, long footerLocation) : Strawberry_TagLib::TagLib::Tag(), d(new TagPrivate()) { -APE::Tag::Tag(Strawberry_TagLib::TagLib::File *file, long footerLocation) : - Strawberry_TagLib::TagLib::Tag(), - d(new TagPrivate()) -{ d->file = file; d->footerLocation = footerLocation; read(); } -APE::Tag::~Tag() -{ +APE::Tag::~Tag() { delete d; } -ByteVector APE::Tag::fileIdentifier() -{ +ByteVector APE::Tag::fileIdentifier() { return ByteVector::fromCString("APETAGEX"); } -String APE::Tag::title() const -{ - if(d->itemListMap["TITLE"].isEmpty()) +String APE::Tag::title() const { + + if (d->itemListMap["TITLE"].isEmpty()) return String(); return d->itemListMap["TITLE"].values().toString(); + } -String APE::Tag::artist() const -{ - if(d->itemListMap["ARTIST"].isEmpty()) +String APE::Tag::artist() const { + + if (d->itemListMap["ARTIST"].isEmpty()) return String(); return d->itemListMap["ARTIST"].values().toString(); + } -String APE::Tag::album() const -{ - if(d->itemListMap["ALBUM"].isEmpty()) +String APE::Tag::album() const { + + if (d->itemListMap["ALBUM"].isEmpty()) return String(); return d->itemListMap["ALBUM"].values().toString(); + } -String APE::Tag::comment() const -{ - if(d->itemListMap["COMMENT"].isEmpty()) +String APE::Tag::comment() const { + + if (d->itemListMap["COMMENT"].isEmpty()) return String(); return d->itemListMap["COMMENT"].values().toString(); + } -String APE::Tag::genre() const -{ - if(d->itemListMap["GENRE"].isEmpty()) +String APE::Tag::genre() const { + + if (d->itemListMap["GENRE"].isEmpty()) return String(); return d->itemListMap["GENRE"].values().toString(); + } -unsigned int APE::Tag::year() const -{ - if(d->itemListMap["YEAR"].isEmpty()) +unsigned int APE::Tag::year() const { + + if (d->itemListMap["YEAR"].isEmpty()) return 0; return d->itemListMap["YEAR"].toString().toInt(); + } -unsigned int APE::Tag::track() const -{ - if(d->itemListMap["TRACK"].isEmpty()) +unsigned int APE::Tag::track() const { + + if (d->itemListMap["TRACK"].isEmpty()) return 0; return d->itemListMap["TRACK"].toString().toInt(); + } -void APE::Tag::setTitle(const String &s) -{ +void APE::Tag::setTitle(const String &s) { addValue("TITLE", s, true); } -void APE::Tag::setArtist(const String &s) -{ +void APE::Tag::setArtist(const String &s) { addValue("ARTIST", s, true); } -void APE::Tag::setAlbum(const String &s) -{ +void APE::Tag::setAlbum(const String &s) { addValue("ALBUM", s, true); } -void APE::Tag::setComment(const String &s) -{ +void APE::Tag::setComment(const String &s) { addValue("COMMENT", s, true); } -void APE::Tag::setGenre(const String &s) -{ +void APE::Tag::setGenre(const String &s) { addValue("GENRE", s, true); } -void APE::Tag::setYear(unsigned int i) -{ - if(i == 0) +void APE::Tag::setYear(unsigned int i) { + if (i == 0) removeItem("YEAR"); else addValue("YEAR", String::number(i), true); } -void APE::Tag::setTrack(unsigned int i) -{ - if(i == 0) +void APE::Tag::setTrack(unsigned int i) { + if (i == 0) removeItem("TRACK"); else addValue("TRACK", String::number(i), true); } -namespace -{ - // conversions of tag keys between what we use in PropertyMap and what's usual - // for APE tags - // usual, APE - const char *keyConversions[][2] = {{"TRACKNUMBER", "TRACK" }, - {"DATE", "YEAR" }, - {"ALBUMARTIST", "ALBUM ARTIST"}, - {"DISCNUMBER", "DISC" }, - {"REMIXER", "MIXARTIST" }}; - const size_t keyConversionsSize = sizeof(keyConversions) / sizeof(keyConversions[0]); -} +namespace { +// conversions of tag keys between what we use in PropertyMap and what's usual +// for APE tags +// usual, APE +const char *keyConversions[][2] = { { "TRACKNUMBER", "TRACK" }, + { "DATE", "YEAR" }, + { "ALBUMARTIST", "ALBUM ARTIST" }, + { "DISCNUMBER", "DISC" }, + { "REMIXER", "MIXARTIST" } }; +const size_t keyConversionsSize = sizeof(keyConversions) / sizeof(keyConversions[0]); +} // namespace -PropertyMap APE::Tag::properties() const -{ +PropertyMap APE::Tag::properties() const { PropertyMap properties; ItemListMap::ConstIterator it = itemListMap().begin(); - for(; it != itemListMap().end(); ++it) { + for (; it != itemListMap().end(); ++it) { String tagName = it->first.upper(); // if the item is Binary or Locator, or if the key is an invalid string, // add to unsupportedData - if(it->second.type() != Item::Text || tagName.isEmpty()) { + if (it->second.type() != Item::Text || tagName.isEmpty()) { properties.unsupportedData().append(it->first); } else { // Some tags need to be handled specially - for(size_t i = 0; i < keyConversionsSize; ++i) { - if(tagName == keyConversions[i][1]) + for (size_t i = 0; i < keyConversionsSize; ++i) { + if (tagName == keyConversions[i][1]) tagName = keyConversions[i][0]; } properties[tagName].append(it->second.toStringList()); @@ -242,20 +228,18 @@ PropertyMap APE::Tag::properties() const return properties; } -void APE::Tag::removeUnsupportedProperties(const StringList &properties) -{ +void APE::Tag::removeUnsupportedProperties(const StringList &properties) { StringList::ConstIterator it = properties.begin(); - for(; it != properties.end(); ++it) + for (; it != properties.end(); ++it) removeItem(*it); } -PropertyMap APE::Tag::setProperties(const PropertyMap &origProps) -{ - PropertyMap properties(origProps); // make a local copy that can be modified +PropertyMap APE::Tag::setProperties(const PropertyMap &origProps) { + PropertyMap properties(origProps); // make a local copy that can be modified // see comment in properties() - for(size_t i = 0; i < keyConversionsSize; ++i) - if(properties.contains(keyConversions[i][0])) { + for (size_t i = 0; i < keyConversionsSize; ++i) + if (properties.contains(keyConversions[i][0])) { properties.insert(keyConversions[i][1], properties[keyConversions[i][0]]); properties.erase(keyConversions[i][0]); } @@ -263,31 +247,31 @@ PropertyMap APE::Tag::setProperties(const PropertyMap &origProps) // first check if tags need to be removed completely StringList toRemove; ItemListMap::ConstIterator remIt = itemListMap().begin(); - for(; remIt != itemListMap().end(); ++remIt) { + for (; remIt != itemListMap().end(); ++remIt) { String key = remIt->first.upper(); // only remove if a) key is valid, b) type is text, c) key not contained in new properties - if(!key.isEmpty() && remIt->second.type() == APE::Item::Text && !properties.contains(key)) + if (!key.isEmpty() && remIt->second.type() == APE::Item::Text && !properties.contains(key)) toRemove.append(remIt->first); } - for(StringList::ConstIterator removeIt = toRemove.begin(); removeIt != toRemove.end(); removeIt++) + for (StringList::ConstIterator removeIt = toRemove.begin(); removeIt != toRemove.end(); removeIt++) removeItem(*removeIt); // now sync in the "forward direction" PropertyMap::ConstIterator it = properties.begin(); PropertyMap invalid; - for(; it != properties.end(); ++it) { + for (; it != properties.end(); ++it) { const String &tagName = it->first; - if(!checkKey(tagName)) + if (!checkKey(tagName)) invalid.insert(it->first, it->second); - else if(!(itemListMap().contains(tagName)) || !(itemListMap()[tagName].values() == it->second)) { - if(it->second.isEmpty()) + else if (!(itemListMap().contains(tagName)) || !(itemListMap()[tagName].values() == it->second)) { + if (it->second.isEmpty()) removeItem(tagName); else { StringList::ConstIterator valueIt = it->second.begin(); addValue(tagName, *valueIt, true); ++valueIt; - for(; valueIt != it->second.end(); ++valueIt) + for (; valueIt != it->second.end(); ++valueIt) addValue(tagName, *valueIt, false); } } @@ -295,35 +279,30 @@ PropertyMap APE::Tag::setProperties(const PropertyMap &origProps) return invalid; } -bool APE::Tag::checkKey(const String &key) -{ - if(key.size() < MinKeyLength || key.size() > MaxKeyLength) +bool APE::Tag::checkKey(const String &key) { + if (key.size() < MinKeyLength || key.size() > MaxKeyLength) return false; return isKeyValid(key.data(String::UTF8)); } -APE::Footer *APE::Tag::footer() const -{ +APE::Footer *APE::Tag::footer() const { return &d->footer; } -const APE::ItemListMap& APE::Tag::itemListMap() const -{ +const APE::ItemListMap &APE::Tag::itemListMap() const { return d->itemListMap; } -void APE::Tag::removeItem(const String &key) -{ +void APE::Tag::removeItem(const String &key) { d->itemListMap.erase(key.upper()); } -void APE::Tag::addValue(const String &key, const String &value, bool replace) -{ - if(replace) +void APE::Tag::addValue(const String &key, const String &value, bool replace) { + if (replace) removeItem(key); - if(value.isEmpty()) + if (value.isEmpty()) return; // Text items may contain more than one value. @@ -331,25 +310,23 @@ void APE::Tag::addValue(const String &key, const String &value, bool replace) ItemListMap::Iterator it = d->itemListMap.find(key.upper()); - if(it != d->itemListMap.end() && it->second.type() == Item::Text) + if (it != d->itemListMap.end() && it->second.type() == Item::Text) it->second.appendValue(value); else setItem(key, Item(key, value)); } -void APE::Tag::setData(const String &key, const ByteVector &value) -{ +void APE::Tag::setData(const String &key, const ByteVector &value) { removeItem(key); - if(value.isEmpty()) + if (value.isEmpty()) return; setItem(key, Item(key, value, true)); } -void APE::Tag::setItem(const String &key, const Item &item) -{ - if(!checkKey(key)) { +void APE::Tag::setItem(const String &key, const Item &item) { + if (!checkKey(key)) { debug("APE::Tag::setItem() - Couldn't set an item due to an invalid key."); return; } @@ -357,8 +334,7 @@ void APE::Tag::setItem(const String &key, const Item &item) d->itemListMap[key.upper()] = item; } -bool APE::Tag::isEmpty() const -{ +bool APE::Tag::isEmpty() const { return d->itemListMap.isEmpty(); } @@ -366,15 +342,14 @@ bool APE::Tag::isEmpty() const // protected methods //////////////////////////////////////////////////////////////////////////////// -void APE::Tag::read() -{ - if(d->file && d->file->isValid()) { +void APE::Tag::read() { + if (d->file && d->file->isValid()) { d->file->seek(d->footerLocation); d->footer.setData(d->file->readBlock(Footer::size())); - if(d->footer.tagSize() <= Footer::size() || - d->footer.tagSize() > static_cast(d->file->length())) + if (d->footer.tagSize() <= Footer::size() || + d->footer.tagSize() > static_cast(d->file->length())) return; d->file->seek(d->footerLocation + Footer::size() - d->footer.tagSize()); @@ -382,12 +357,11 @@ void APE::Tag::read() } } -ByteVector APE::Tag::render() const -{ +ByteVector APE::Tag::render() const { ByteVector data; unsigned int itemCount = 0; - for(ItemListMap::ConstIterator it = d->itemListMap.begin(); it != d->itemListMap.end(); ++it) { + for (ItemListMap::ConstIterator it = d->itemListMap.begin(); it != d->itemListMap.end(); ++it) { data.append(it->second.render()); itemCount++; } @@ -399,19 +373,18 @@ ByteVector APE::Tag::render() const return d->footer.renderHeader() + data + d->footer.renderFooter(); } -void APE::Tag::parse(const ByteVector &data) -{ +void APE::Tag::parse(const ByteVector &data) { // 11 bytes is the minimum size for an APE item - if(data.size() < 11) + if (data.size() < 11) return; unsigned int pos = 0; - for(unsigned int i = 0; i < d->footer.itemCount() && pos <= data.size() - 11; i++) { + for (unsigned int i = 0; i < d->footer.itemCount() && pos <= data.size() - 11; i++) { const int nullPos = data.find('\0', pos + 8); - if(nullPos < 0) { + if (nullPos < 0) { debug("APE::Tag::parse() - Couldn't find a key/value separator. Stopped parsing."); return; } @@ -419,10 +392,7 @@ void APE::Tag::parse(const ByteVector &data) const unsigned int keyLength = nullPos - pos - 8; const unsigned int valLegnth = data.toUInt(pos, false); - if(keyLength >= MinKeyLength - && keyLength <= MaxKeyLength - && isKeyValid(data.mid(pos + 8, keyLength))) - { + if (keyLength >= MinKeyLength && keyLength <= MaxKeyLength && isKeyValid(data.mid(pos + 8, keyLength))) { APE::Item item; item.parse(data.mid(pos)); diff --git a/3rdparty/taglib/ape/apetag.h b/3rdparty/taglib/ape/apetag.h index f107b845f..95e2bef91 100644 --- a/3rdparty/taglib/ape/apetag.h +++ b/3rdparty/taglib/ape/apetag.h @@ -37,74 +37,73 @@ namespace Strawberry_TagLib { namespace TagLib { - class File; +class File; - //! An implementation of the APE tagging format +//! An implementation of the APE tagging format - namespace APE { +namespace APE { - class Footer; +class Footer; - /*! +/*! * A mapping between a list of item names, or keys, and the associated item. * * \see APE::Tag::itemListMap() */ - typedef Map ItemListMap; +typedef Map ItemListMap; - //! An APE tag implementation +//! An APE tag implementation - class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag - { - public: - /*! +class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag { + public: + /*! * Create an APE tag with default values. */ - Tag(); + Tag(); - /*! + /*! * Create an APE tag and parse the data in \a file with APE footer at * \a tagOffset. */ - Tag(Strawberry_TagLib::TagLib::File *file, long footerLocation); + Tag(Strawberry_TagLib::TagLib::File *file, long footerLocation); - /*! + /*! * Destroys this Tag instance. */ - virtual ~Tag(); + virtual ~Tag(); - /*! + /*! * Renders the in memory values to a ByteVector suitable for writing to * the file. */ - ByteVector render() const; + ByteVector render() const; - /*! + /*! * Returns the string "APETAGEX" suitable for usage in locating the tag in a * file. */ - static ByteVector fileIdentifier(); + static ByteVector fileIdentifier(); - // Reimplementations. + // Reimplementations. - virtual String title() const; - virtual String artist() const; - virtual String album() const; - virtual String comment() const; - virtual String genre() const; - virtual unsigned int year() const; - virtual unsigned int track() const; + virtual String title() const; + virtual String artist() const; + virtual String album() const; + virtual String comment() const; + virtual String genre() const; + virtual unsigned int year() const; + virtual unsigned int track() const; - virtual void setTitle(const String &s); - virtual void setArtist(const String &s); - virtual void setAlbum(const String &s); - virtual void setComment(const String &s); - virtual void setGenre(const String &s); - virtual void setYear(unsigned int i); - virtual void setTrack(unsigned int i); + virtual void setTitle(const String &s); + virtual void setArtist(const String &s); + virtual void setAlbum(const String &s); + virtual void setComment(const String &s); + virtual void setGenre(const String &s); + virtual void setYear(unsigned int i); + virtual void setTrack(unsigned int i); - /*! + /*! * Implements the unified tag dictionary interface -- export function. * APE tags are perfectly compatible with the dictionary interface because they * support both arbitrary tag names and multiple values. Currently only @@ -118,29 +117,29 @@ namespace TagLib { * TRACK to TRACKNUMBER, YEAR to DATE, and ALBUM ARTIST to ALBUMARTIST, respectively, * in order to be compliant with the names used in other formats. */ - PropertyMap properties() const; + PropertyMap properties() const; - void removeUnsupportedProperties(const StringList &properties); + void removeUnsupportedProperties(const StringList &properties); - /*! + /*! * Implements the unified tag dictionary interface -- import function. The same * comments as for the export function apply; additionally note that the APE tag * specification requires keys to have between 2 and 16 printable ASCII characters * with the exception of the fixed strings "ID3", "TAG", "OGGS", and "MP+". */ - PropertyMap setProperties(const PropertyMap &); + PropertyMap setProperties(const PropertyMap &); - /*! + /*! * Check if the given String is a valid APE tag key. */ - static bool checkKey(const String&); + static bool checkKey(const String &); - /*! + /*! * Returns a pointer to the tag's footer. */ - Footer *footer() const; + Footer *footer() const; - /*! + /*! * Returns a reference to the item list map. This is an ItemListMap of * all of the items in the tag. * @@ -152,59 +151,58 @@ namespace TagLib { * \warning You should not modify this data structure directly, instead * use setItem() and removeItem(). */ - const ItemListMap &itemListMap() const; + const ItemListMap &itemListMap() const; - /*! + /*! * Removes the \a key item from the tag */ - void removeItem(const String &key); + void removeItem(const String &key); - /*! + /*! * Adds to the text item specified by \a key the data \a value. If \a replace * is true, then all of the other values on the same key will be removed * first. If a binary item exists for \a key it will be removed first. */ - void addValue(const String &key, const String &value, bool replace = true); + void addValue(const String &key, const String &value, bool replace = true); - /*! + /*! * Set the binary data for the key specified by \a item to \a value * This will convert the item to type \a Binary if it isn't already and * all of the other values on the same key will be removed. */ - void setData(const String &key, const ByteVector &value); + void setData(const String &key, const ByteVector &value); - /*! + /*! * Sets the \a key item to the value of \a item. If an item with the \a key is already * present, it will be replaced. */ - void setItem(const String &key, const Item &item); + void setItem(const String &key, const Item &item); - /*! + /*! * Returns true if the tag does not contain any data. */ - bool isEmpty() const; + bool isEmpty() const; - protected: - - /*! + protected: + /*! * Reads from the file specified in the constructor. */ - void read(); + void read(); - /*! + /*! * Parses the body of the tag in \a data. */ - void parse(const ByteVector &data); + void parse(const ByteVector &data); - private: - Tag(const Tag &); - Tag &operator=(const Tag &); + private: + Tag(const Tag &); + Tag &operator=(const Tag &); - class TagPrivate; - TagPrivate *d; - }; - } -} -} + class TagPrivate; + TagPrivate *d; +}; +} // namespace APE +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/asf/asfattribute.cpp b/3rdparty/taglib/asf/asfattribute.cpp index a535a50b7..2c9e162fd 100644 --- a/3rdparty/taglib/asf/asfattribute.cpp +++ b/3rdparty/taglib/asf/asfattribute.cpp @@ -33,14 +33,12 @@ using namespace Strawberry_TagLib::TagLib; -class ASF::Attribute::AttributePrivate : public RefCounter -{ -public: - AttributePrivate() : - pictureValue(ASF::Picture::fromInvalid()), - numericValue(0), - stream(0), - language(0) {} +class ASF::Attribute::AttributePrivate : public RefCounter { + public: + AttributePrivate() : pictureValue(ASF::Picture::fromInvalid()), + numericValue(0), + stream(0), + language(0) {} AttributeTypes type; String stringValue; ByteVector byteVectorValue; @@ -54,135 +52,105 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -ASF::Attribute::Attribute() : - d(new AttributePrivate()) -{ +ASF::Attribute::Attribute() : d(new AttributePrivate()) { d->type = UnicodeType; } -ASF::Attribute::Attribute(const ASF::Attribute &other) : - d(other.d) -{ +ASF::Attribute::Attribute(const ASF::Attribute &other) : d(other.d) { d->ref(); } -ASF::Attribute::Attribute(const String &value) : - d(new AttributePrivate()) -{ +ASF::Attribute::Attribute(const String &value) : d(new AttributePrivate()) { d->type = UnicodeType; d->stringValue = value; } -ASF::Attribute::Attribute(const ByteVector &value) : - d(new AttributePrivate()) -{ +ASF::Attribute::Attribute(const ByteVector &value) : d(new AttributePrivate()) { d->type = BytesType; d->byteVectorValue = value; } -ASF::Attribute::Attribute(const ASF::Picture &value) : - d(new AttributePrivate()) -{ +ASF::Attribute::Attribute(const ASF::Picture &value) : d(new AttributePrivate()) { d->type = BytesType; d->pictureValue = value; } -ASF::Attribute::Attribute(unsigned int value) : - d(new AttributePrivate()) -{ +ASF::Attribute::Attribute(unsigned int value) : d(new AttributePrivate()) { d->type = DWordType; d->numericValue = value; } -ASF::Attribute::Attribute(unsigned long long value) : - d(new AttributePrivate()) -{ +ASF::Attribute::Attribute(unsigned long long value) : d(new AttributePrivate()) { d->type = QWordType; d->numericValue = value; } -ASF::Attribute::Attribute(unsigned short value) : - d(new AttributePrivate()) -{ +ASF::Attribute::Attribute(unsigned short value) : d(new AttributePrivate()) { d->type = WordType; d->numericValue = value; } -ASF::Attribute::Attribute(bool value) : - d(new AttributePrivate()) -{ +ASF::Attribute::Attribute(bool value) : d(new AttributePrivate()) { d->type = BoolType; d->numericValue = value; } -ASF::Attribute &ASF::Attribute::operator=(const ASF::Attribute &other) -{ +ASF::Attribute &ASF::Attribute::operator=(const ASF::Attribute &other) { Attribute(other).swap(*this); return *this; } -void ASF::Attribute::swap(Attribute &other) -{ +void ASF::Attribute::swap(Attribute &other) { using std::swap; swap(d, other.d); } -ASF::Attribute::~Attribute() -{ - if(d->deref()) +ASF::Attribute::~Attribute() { + if (d->deref()) delete d; } -ASF::Attribute::AttributeTypes ASF::Attribute::type() const -{ +ASF::Attribute::AttributeTypes ASF::Attribute::type() const { return d->type; } -String ASF::Attribute::toString() const -{ +String ASF::Attribute::toString() const { return d->stringValue; } -ByteVector ASF::Attribute::toByteVector() const -{ - if(d->pictureValue.isValid()) +ByteVector ASF::Attribute::toByteVector() const { + if (d->pictureValue.isValid()) return d->pictureValue.render(); return d->byteVectorValue; } -unsigned short ASF::Attribute::toBool() const -{ +unsigned short ASF::Attribute::toBool() const { return d->numericValue ? 1 : 0; } -unsigned short ASF::Attribute::toUShort() const -{ +unsigned short ASF::Attribute::toUShort() const { return static_cast(d->numericValue); } -unsigned int ASF::Attribute::toUInt() const -{ +unsigned int ASF::Attribute::toUInt() const { return static_cast(d->numericValue); } -unsigned long long ASF::Attribute::toULongLong() const -{ +unsigned long long ASF::Attribute::toULongLong() const { return static_cast(d->numericValue); } -ASF::Picture ASF::Attribute::toPicture() const -{ +ASF::Picture ASF::Attribute::toPicture() const { return d->pictureValue; } -String ASF::Attribute::parse(ASF::File &f, int kind) -{ +String ASF::Attribute::parse(ASF::File &f, int kind) { unsigned int size, nameLength; String name; d->pictureValue = Picture::fromInvalid(); // extended content descriptor - if(kind == 0) { + if (kind == 0) { nameLength = readWORD(&f); name = readString(&f, nameLength); d->type = ASF::Attribute::AttributeTypes(readWORD(&f)); @@ -192,7 +160,7 @@ String ASF::Attribute::parse(ASF::File &f, int kind) else { int temp = readWORD(&f); // metadata library - if(kind == 2) { + if (kind == 2) { d->language = temp; } d->stream = readWORD(&f); @@ -202,45 +170,45 @@ String ASF::Attribute::parse(ASF::File &f, int kind) name = readString(&f, nameLength); } - if(kind != 2 && size > 65535) { + if (kind != 2 && size > 65535) { debug("ASF::Attribute::parse() -- Value larger than 64kB"); } - switch(d->type) { - case WordType: - d->numericValue = readWORD(&f); - break; + switch (d->type) { + case WordType: + d->numericValue = readWORD(&f); + break; - case BoolType: - if(kind == 0) { - d->numericValue = (readDWORD(&f) != 0); - } - else { - d->numericValue = (readWORD(&f) != 0); - } - break; + case BoolType: + if (kind == 0) { + d->numericValue = (readDWORD(&f) != 0); + } + else { + d->numericValue = (readWORD(&f) != 0); + } + break; - case DWordType: - d->numericValue = readDWORD(&f); - break; + case DWordType: + d->numericValue = readDWORD(&f); + break; - case QWordType: - d->numericValue = readQWORD(&f); - break; + case QWordType: + d->numericValue = readQWORD(&f); + break; - case UnicodeType: - d->stringValue = readString(&f, size); - break; + case UnicodeType: + d->stringValue = readString(&f, size); + break; - case BytesType: - case GuidType: - d->byteVectorValue = f.readBlock(size); - break; + case BytesType: + case GuidType: + d->byteVectorValue = f.readBlock(size); + break; } - if(d->type == BytesType && name == "WM/Picture") { + if (d->type == BytesType && name == "WM/Picture") { d->pictureValue.parse(d->byteVectorValue); - if(d->pictureValue.isValid()) { + if (d->pictureValue.isValid()) { d->byteVectorValue.clear(); } } @@ -248,106 +216,100 @@ String ASF::Attribute::parse(ASF::File &f, int kind) return name; } -int ASF::Attribute::dataSize() const -{ +int ASF::Attribute::dataSize() const { switch (d->type) { - case WordType: - return 2; - case BoolType: - return 4; - case DWordType: - return 4; - case QWordType: - return 5; - case UnicodeType: - return d->stringValue.size() * 2 + 2; - case BytesType: - if(d->pictureValue.isValid()) - return d->pictureValue.dataSize(); - break; - case GuidType: - return d->byteVectorValue.size(); + case WordType: + return 2; + case BoolType: + return 4; + case DWordType: + return 4; + case QWordType: + return 5; + case UnicodeType: + return d->stringValue.size() * 2 + 2; + case BytesType: + if (d->pictureValue.isValid()) + return d->pictureValue.dataSize(); + break; + case GuidType: + return d->byteVectorValue.size(); } return 0; } -ByteVector ASF::Attribute::render(const String &name, int kind) const -{ +ByteVector ASF::Attribute::render(const String &name, int kind) const { ByteVector data; switch (d->type) { - case WordType: - data.append(ByteVector::fromShort(toUShort(), false)); - break; - - case BoolType: - if(kind == 0) { - data.append(ByteVector::fromUInt(toBool(), false)); - } - else { - data.append(ByteVector::fromShort(toBool(), false)); - } - break; - - case DWordType: - data.append(ByteVector::fromUInt(toUInt(), false)); - break; - - case QWordType: - data.append(ByteVector::fromLongLong(toULongLong(), false)); - break; - - case UnicodeType: - data.append(renderString(d->stringValue)); - break; - - case BytesType: - if(d->pictureValue.isValid()) { - data.append(d->pictureValue.render()); + case WordType: + data.append(ByteVector::fromShort(toUShort(), false)); + break; + + case BoolType: + if (kind == 0) { + data.append(ByteVector::fromUInt(toBool(), false)); + } + else { + data.append(ByteVector::fromShort(toBool(), false)); + } + break; + + case DWordType: + data.append(ByteVector::fromUInt(toUInt(), false)); + break; + + case QWordType: + data.append(ByteVector::fromLongLong(toULongLong(), false)); + break; + + case UnicodeType: + data.append(renderString(d->stringValue)); + break; + + case BytesType: + if (d->pictureValue.isValid()) { + data.append(d->pictureValue.render()); + break; + } + break; + case GuidType: + data.append(d->byteVectorValue); break; - } - break; - case GuidType: - data.append(d->byteVectorValue); - break; } - if(kind == 0) { + if (kind == 0) { data = renderString(name, true) + - ByteVector::fromShort((int)d->type, false) + - ByteVector::fromShort(data.size(), false) + - data; + ByteVector::fromShort((int)d->type, false) + + ByteVector::fromShort(data.size(), false) + + data; } else { ByteVector nameData = renderString(name); data = ByteVector::fromShort(kind == 2 ? d->language : 0, false) + - ByteVector::fromShort(d->stream, false) + - ByteVector::fromShort(nameData.size(), false) + - ByteVector::fromShort((int)d->type, false) + - ByteVector::fromUInt(data.size(), false) + - nameData + - data; + ByteVector::fromShort(d->stream, false) + + ByteVector::fromShort(nameData.size(), false) + + ByteVector::fromShort((int)d->type, false) + + ByteVector::fromUInt(data.size(), false) + + nameData + + data; } return data; } -int ASF::Attribute::language() const -{ +int ASF::Attribute::language() const { return d->language; } -void ASF::Attribute::setLanguage(int value) -{ +void ASF::Attribute::setLanguage(int value) { d->language = value; } -int ASF::Attribute::stream() const -{ +int ASF::Attribute::stream() const { return d->stream; } -void ASF::Attribute::setStream(int value) -{ +void ASF::Attribute::setStream(int value) { d->stream = value; } diff --git a/3rdparty/taglib/asf/asfattribute.h b/3rdparty/taglib/asf/asfattribute.h index a83f20e24..aaa32a0df 100644 --- a/3rdparty/taglib/asf/asfattribute.h +++ b/3rdparty/taglib/asf/asfattribute.h @@ -32,48 +32,44 @@ #include "asfpicture.h" namespace Strawberry_TagLib { -namespace TagLib -{ +namespace TagLib { - namespace ASF - { +namespace ASF { - class File; - class Picture; +class File; +class Picture; - class TAGLIB_EXPORT Attribute - { - public: - - /*! +class TAGLIB_EXPORT Attribute { + public: + /*! * Enum of types an Attribute can have. */ - enum AttributeTypes { - UnicodeType = 0, - BytesType = 1, - BoolType = 2, - DWordType = 3, - QWordType = 4, - WordType = 5, - GuidType = 6 - }; + enum AttributeTypes { + UnicodeType = 0, + BytesType = 1, + BoolType = 2, + DWordType = 3, + QWordType = 4, + WordType = 5, + GuidType = 6 + }; - /*! + /*! * Constructs an empty attribute. */ - Attribute(); + Attribute(); - /*! + /*! * Constructs an attribute with \a key and a UnicodeType \a value. */ - Attribute(const String &value); + Attribute(const String &value); - /*! + /*! * Constructs an attribute with \a key and a BytesType \a value. */ - Attribute(const ByteVector &value); + Attribute(const ByteVector &value); - /*! + /*! * Constructs an attribute with \a key and a Picture \a value. * * This attribute is compatible with the ID3 frame, APIC. The ID3 specification for the APIC frame stipulates that, @@ -84,127 +80,127 @@ namespace TagLib * WM/Picture attributes added with TagLib::ASF are not automatically validated to conform to ID3 specifications. * You must add code in your application to perform validations if you want to maintain complete compatibility with ID3. */ - Attribute(const Picture &value); + Attribute(const Picture &value); - /*! + /*! * Constructs an attribute with \a key and a DWordType \a value. */ - Attribute(unsigned int value); + Attribute(unsigned int value); - /*! + /*! * Constructs an attribute with \a key and a QWordType \a value. */ - Attribute(unsigned long long value); + Attribute(unsigned long long value); - /*! + /*! * Constructs an attribute with \a key and a WordType \a value. */ - Attribute(unsigned short value); + Attribute(unsigned short value); - /*! + /*! * Constructs an attribute with \a key and a BoolType \a value. */ - Attribute(bool value); + Attribute(bool value); - /*! + /*! * Construct an attribute as a copy of \a other. */ - Attribute(const Attribute &item); + Attribute(const Attribute &item); - /*! + /*! * Copies the contents of \a other into this item. */ - Attribute &operator=(const Attribute &other); + Attribute &operator=(const Attribute &other); - /*! + /*! * Exchanges the content of the Attribute by the content of \a other. */ - void swap(Attribute &other); + void swap(Attribute &other); - /*! + /*! * Destroys the attribute. */ - virtual ~Attribute(); + virtual ~Attribute(); - /*! + /*! * Returns type of the value. */ - AttributeTypes type() const; + AttributeTypes type() const; - /*! + /*! * Returns the BoolType \a value. */ - unsigned short toBool() const; + unsigned short toBool() const; - /*! + /*! * Returns the WordType \a value. */ - unsigned short toUShort() const; + unsigned short toUShort() const; - /*! + /*! * Returns the DWordType \a value. */ - unsigned int toUInt() const; + unsigned int toUInt() const; - /*! + /*! * Returns the QWordType \a value. */ - unsigned long long toULongLong() const; + unsigned long long toULongLong() const; - /*! + /*! * Returns the UnicodeType \a value. */ - String toString() const; + String toString() const; - /*! + /*! * Returns the BytesType \a value. */ - ByteVector toByteVector() const; + ByteVector toByteVector() const; - /*! + /*! * Returns the Picture \a value. */ - Picture toPicture() const; + Picture toPicture() const; - /*! + /*! * Returns the language number, or 0 is no stream number was set. */ - int language() const; + int language() const; - /*! + /*! * Sets the language number. */ - void setLanguage(int value); + void setLanguage(int value); - /*! + /*! * Returns the stream number, or 0 is no stream number was set. */ - int stream() const; + int stream() const; - /*! + /*! * Sets the stream number. */ - void setStream(int value); + void setStream(int value); #ifndef DO_NOT_DOCUMENT - /* THIS IS PRIVATE, DON'T TOUCH IT! */ - String parse(ASF::File &file, int kind = 0); + /* THIS IS PRIVATE, DON'T TOUCH IT! */ + String parse(ASF::File &file, int kind = 0); #endif - //! Returns the size of the stored data - int dataSize() const; + //! Returns the size of the stored data + int dataSize() const; - private: - friend class File; + private: + friend class File; - ByteVector render(const String &name, int kind = 0) const; + ByteVector render(const String &name, int kind = 0) const; - class AttributePrivate; - AttributePrivate *d; - }; - } + class AttributePrivate; + AttributePrivate *d; +}; +} // namespace ASF -} -} +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/asf/asffile.cpp b/3rdparty/taglib/asf/asffile.cpp index a228883f3..e64d7a2e0 100644 --- a/3rdparty/taglib/asf/asffile.cpp +++ b/3rdparty/taglib/asf/asffile.cpp @@ -36,9 +36,8 @@ using namespace Strawberry_TagLib::TagLib; -class ASF::File::FilePrivate -{ -public: +class ASF::File::FilePrivate { + public: class BaseObject; class UnknownObject; class FilePropertiesObject; @@ -50,21 +49,18 @@ public: class MetadataObject; class MetadataLibraryObject; - FilePrivate(): - headerSize(0), - tag(0), - properties(0), - contentDescriptionObject(0), - extendedContentDescriptionObject(0), - headerExtensionObject(0), - metadataObject(0), - metadataLibraryObject(0) - { + FilePrivate() : headerSize(0), + tag(0), + properties(0), + contentDescriptionObject(0), + extendedContentDescriptionObject(0), + headerExtensionObject(0), + metadataObject(0), + metadataLibraryObject(0) { objects.setAutoDelete(true); } - ~FilePrivate() - { + ~FilePrivate() { delete tag; delete properties; } @@ -76,32 +72,30 @@ public: List objects; - ContentDescriptionObject *contentDescriptionObject; + ContentDescriptionObject *contentDescriptionObject; ExtendedContentDescriptionObject *extendedContentDescriptionObject; - HeaderExtensionObject *headerExtensionObject; - MetadataObject *metadataObject; - MetadataLibraryObject *metadataLibraryObject; + HeaderExtensionObject *headerExtensionObject; + MetadataObject *metadataObject; + MetadataLibraryObject *metadataLibraryObject; }; -namespace -{ - const ByteVector headerGuid("\x30\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C", 16); - const ByteVector filePropertiesGuid("\xA1\xDC\xAB\x8C\x47\xA9\xCF\x11\x8E\xE4\x00\xC0\x0C\x20\x53\x65", 16); - const ByteVector streamPropertiesGuid("\x91\x07\xDC\xB7\xB7\xA9\xCF\x11\x8E\xE6\x00\xC0\x0C\x20\x53\x65", 16); - const ByteVector contentDescriptionGuid("\x33\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C", 16); - const ByteVector extendedContentDescriptionGuid("\x40\xA4\xD0\xD2\x07\xE3\xD2\x11\x97\xF0\x00\xA0\xC9\x5E\xA8\x50", 16); - const ByteVector headerExtensionGuid("\xb5\x03\xbf_.\xa9\xcf\x11\x8e\xe3\x00\xc0\x0c Se", 16); - const ByteVector metadataGuid("\xEA\xCB\xF8\xC5\xAF[wH\204g\xAA\214D\xFAL\xCA", 16); - const ByteVector metadataLibraryGuid("\224\034#D\230\224\321I\241A\x1d\x13NEpT", 16); - const ByteVector codecListGuid("\x40\x52\xd1\x86\x1d\x31\xd0\x11\xa3\xa4\x00\xa0\xc9\x03\x48\xf6", 16); - const ByteVector contentEncryptionGuid("\xFB\xB3\x11\x22\x23\xBD\xD2\x11\xB4\xB7\x00\xA0\xC9\x55\xFC\x6E", 16); - const ByteVector extendedContentEncryptionGuid("\x14\xE6\x8A\x29\x22\x26 \x17\x4C\xB9\x35\xDA\xE0\x7E\xE9\x28\x9C", 16); - const ByteVector advancedContentEncryptionGuid("\xB6\x9B\x07\x7A\xA4\xDA\x12\x4E\xA5\xCA\x91\xD3\x8D\xC1\x1A\x8D", 16); -} +namespace { +const ByteVector headerGuid("\x30\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C", 16); +const ByteVector filePropertiesGuid("\xA1\xDC\xAB\x8C\x47\xA9\xCF\x11\x8E\xE4\x00\xC0\x0C\x20\x53\x65", 16); +const ByteVector streamPropertiesGuid("\x91\x07\xDC\xB7\xB7\xA9\xCF\x11\x8E\xE6\x00\xC0\x0C\x20\x53\x65", 16); +const ByteVector contentDescriptionGuid("\x33\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C", 16); +const ByteVector extendedContentDescriptionGuid("\x40\xA4\xD0\xD2\x07\xE3\xD2\x11\x97\xF0\x00\xA0\xC9\x5E\xA8\x50", 16); +const ByteVector headerExtensionGuid("\xb5\x03\xbf_.\xa9\xcf\x11\x8e\xe3\x00\xc0\x0c Se", 16); +const ByteVector metadataGuid("\xEA\xCB\xF8\xC5\xAF[wH\204g\xAA\214D\xFAL\xCA", 16); +const ByteVector metadataLibraryGuid("\224\034#D\230\224\321I\241A\x1d\x13NEpT", 16); +const ByteVector codecListGuid("\x40\x52\xd1\x86\x1d\x31\xd0\x11\xa3\xa4\x00\xa0\xc9\x03\x48\xf6", 16); +const ByteVector contentEncryptionGuid("\xFB\xB3\x11\x22\x23\xBD\xD2\x11\xB4\xB7\x00\xA0\xC9\x55\xFC\x6E", 16); +const ByteVector extendedContentEncryptionGuid("\x14\xE6\x8A\x29\x22\x26 \x17\x4C\xB9\x35\xDA\xE0\x7E\xE9\x28\x9C", 16); +const ByteVector advancedContentEncryptionGuid("\xB6\x9B\x07\x7A\xA4\xDA\x12\x4E\xA5\xCA\x91\xD3\x8D\xC1\x1A\x8D", 16); +} // namespace -class ASF::File::FilePrivate::BaseObject -{ -public: +class ASF::File::FilePrivate::BaseObject { + public: ByteVector data; virtual ~BaseObject() {} virtual ByteVector guid() const = 0; @@ -109,66 +103,59 @@ public: virtual ByteVector render(ASF::File *file); }; -class ASF::File::FilePrivate::UnknownObject : public ASF::File::FilePrivate::BaseObject -{ +class ASF::File::FilePrivate::UnknownObject : public ASF::File::FilePrivate::BaseObject { ByteVector myGuid; -public: + + public: explicit UnknownObject(const ByteVector &guid); ByteVector guid() const; }; -class ASF::File::FilePrivate::FilePropertiesObject : public ASF::File::FilePrivate::BaseObject -{ -public: +class ASF::File::FilePrivate::FilePropertiesObject : public ASF::File::FilePrivate::BaseObject { + public: ByteVector guid() const; void parse(ASF::File *file, unsigned int size); }; -class ASF::File::FilePrivate::StreamPropertiesObject : public ASF::File::FilePrivate::BaseObject -{ -public: +class ASF::File::FilePrivate::StreamPropertiesObject : public ASF::File::FilePrivate::BaseObject { + public: ByteVector guid() const; void parse(ASF::File *file, unsigned int size); }; -class ASF::File::FilePrivate::ContentDescriptionObject : public ASF::File::FilePrivate::BaseObject -{ -public: +class ASF::File::FilePrivate::ContentDescriptionObject : public ASF::File::FilePrivate::BaseObject { + public: ByteVector guid() const; void parse(ASF::File *file, unsigned int size); ByteVector render(ASF::File *file); }; -class ASF::File::FilePrivate::ExtendedContentDescriptionObject : public ASF::File::FilePrivate::BaseObject -{ -public: +class ASF::File::FilePrivate::ExtendedContentDescriptionObject : public ASF::File::FilePrivate::BaseObject { + public: ByteVectorList attributeData; ByteVector guid() const; void parse(ASF::File *file, unsigned int size); ByteVector render(ASF::File *file); }; -class ASF::File::FilePrivate::MetadataObject : public ASF::File::FilePrivate::BaseObject -{ -public: +class ASF::File::FilePrivate::MetadataObject : public ASF::File::FilePrivate::BaseObject { + public: ByteVectorList attributeData; ByteVector guid() const; void parse(ASF::File *file, unsigned int size); ByteVector render(ASF::File *file); }; -class ASF::File::FilePrivate::MetadataLibraryObject : public ASF::File::FilePrivate::BaseObject -{ -public: +class ASF::File::FilePrivate::MetadataLibraryObject : public ASF::File::FilePrivate::BaseObject { + public: ByteVectorList attributeData; ByteVector guid() const; void parse(ASF::File *file, unsigned int size); ByteVector render(ASF::File *file); }; -class ASF::File::FilePrivate::HeaderExtensionObject : public ASF::File::FilePrivate::BaseObject -{ -public: +class ASF::File::FilePrivate::HeaderExtensionObject : public ASF::File::FilePrivate::BaseObject { + public: List objects; HeaderExtensionObject(); ByteVector guid() const; @@ -176,71 +163,61 @@ public: ByteVector render(ASF::File *file); }; -class ASF::File::FilePrivate::CodecListObject : public ASF::File::FilePrivate::BaseObject -{ -public: +class ASF::File::FilePrivate::CodecListObject : public ASF::File::FilePrivate::BaseObject { + public: ByteVector guid() const; void parse(ASF::File *file, unsigned int size); -private: - enum CodecType - { - Video = 0x0001, - Audio = 0x0002, + private: + enum CodecType { + Video = 0x0001, + Audio = 0x0002, Unknown = 0xFFFF }; }; -void ASF::File::FilePrivate::BaseObject::parse(ASF::File *file, unsigned int size) -{ +void ASF::File::FilePrivate::BaseObject::parse(ASF::File *file, unsigned int size) { data.clear(); - if(size > 24 && size <= (unsigned int)(file->length())) + if (size > 24 && size <= (unsigned int)(file->length())) data = file->readBlock(size - 24); else data = ByteVector(); } -ByteVector ASF::File::FilePrivate::BaseObject::render(ASF::File * /*file*/) -{ +ByteVector ASF::File::FilePrivate::BaseObject::render(ASF::File * /*file*/) { return guid() + ByteVector::fromLongLong(data.size() + 24, false) + data; } -ASF::File::FilePrivate::UnknownObject::UnknownObject(const ByteVector &guid) : myGuid(guid) -{ +ASF::File::FilePrivate::UnknownObject::UnknownObject(const ByteVector &guid) : myGuid(guid) { } -ByteVector ASF::File::FilePrivate::UnknownObject::guid() const -{ +ByteVector ASF::File::FilePrivate::UnknownObject::guid() const { return myGuid; } -ByteVector ASF::File::FilePrivate::FilePropertiesObject::guid() const -{ +ByteVector ASF::File::FilePrivate::FilePropertiesObject::guid() const { return filePropertiesGuid; } -void ASF::File::FilePrivate::FilePropertiesObject::parse(ASF::File *file, unsigned int size) -{ +void ASF::File::FilePrivate::FilePropertiesObject::parse(ASF::File *file, unsigned int size) { BaseObject::parse(file, size); - if(data.size() < 64) { + if (data.size() < 64) { debug("ASF::File::FilePrivate::FilePropertiesObject::parse() -- data is too short."); return; } const long long duration = data.toLongLong(40, false); - const long long preroll = data.toLongLong(56, false); + const long long preroll = data.toLongLong(56, false); file->d->properties->setLengthInMilliseconds(static_cast(duration / 10000.0 - preroll + 0.5)); } -ByteVector ASF::File::FilePrivate::StreamPropertiesObject::guid() const -{ +ByteVector ASF::File::FilePrivate::StreamPropertiesObject::guid() const { return streamPropertiesGuid; } -void ASF::File::FilePrivate::StreamPropertiesObject::parse(ASF::File *file, unsigned int size) -{ +void ASF::File::FilePrivate::StreamPropertiesObject::parse(ASF::File *file, unsigned int size) { BaseObject::parse(file, size); - if(data.size() < 70) { + if (data.size() < 70) { debug("ASF::File::FilePrivate::StreamPropertiesObject::parse() -- data is too short."); return; } @@ -252,27 +229,24 @@ void ASF::File::FilePrivate::StreamPropertiesObject::parse(ASF::File *file, unsi file->d->properties->setBitsPerSample(data.toUShort(68, false)); } -ByteVector ASF::File::FilePrivate::ContentDescriptionObject::guid() const -{ +ByteVector ASF::File::FilePrivate::ContentDescriptionObject::guid() const { return contentDescriptionGuid; } -void ASF::File::FilePrivate::ContentDescriptionObject::parse(ASF::File *file, unsigned int /*size*/) -{ - const int titleLength = readWORD(file); - const int artistLength = readWORD(file); +void ASF::File::FilePrivate::ContentDescriptionObject::parse(ASF::File *file, unsigned int /*size*/) { + const int titleLength = readWORD(file); + const int artistLength = readWORD(file); const int copyrightLength = readWORD(file); - const int commentLength = readWORD(file); - const int ratingLength = readWORD(file); - file->d->tag->setTitle(readString(file,titleLength)); - file->d->tag->setArtist(readString(file,artistLength)); - file->d->tag->setCopyright(readString(file,copyrightLength)); - file->d->tag->setComment(readString(file,commentLength)); - file->d->tag->setRating(readString(file,ratingLength)); + const int commentLength = readWORD(file); + const int ratingLength = readWORD(file); + file->d->tag->setTitle(readString(file, titleLength)); + file->d->tag->setArtist(readString(file, artistLength)); + file->d->tag->setCopyright(readString(file, copyrightLength)); + file->d->tag->setComment(readString(file, commentLength)); + file->d->tag->setRating(readString(file, ratingLength)); } -ByteVector ASF::File::FilePrivate::ContentDescriptionObject::render(ASF::File *file) -{ +ByteVector ASF::File::FilePrivate::ContentDescriptionObject::render(ASF::File *file) { const ByteVector v1 = renderString(file->d->tag->title()); const ByteVector v2 = renderString(file->d->tag->artist()); const ByteVector v3 = renderString(file->d->tag->copyright()); @@ -292,108 +266,96 @@ ByteVector ASF::File::FilePrivate::ContentDescriptionObject::render(ASF::File *f return BaseObject::render(file); } -ByteVector ASF::File::FilePrivate::ExtendedContentDescriptionObject::guid() const -{ +ByteVector ASF::File::FilePrivate::ExtendedContentDescriptionObject::guid() const { return extendedContentDescriptionGuid; } -void ASF::File::FilePrivate::ExtendedContentDescriptionObject::parse(ASF::File *file, unsigned int /*size*/) -{ +void ASF::File::FilePrivate::ExtendedContentDescriptionObject::parse(ASF::File *file, unsigned int /*size*/) { int count = readWORD(file); - while(count--) { + while (count--) { ASF::Attribute attribute; String name = attribute.parse(*file); file->d->tag->addAttribute(name, attribute); } } -ByteVector ASF::File::FilePrivate::ExtendedContentDescriptionObject::render(ASF::File *file) -{ +ByteVector ASF::File::FilePrivate::ExtendedContentDescriptionObject::render(ASF::File *file) { data.clear(); data.append(ByteVector::fromShort(attributeData.size(), false)); data.append(attributeData.toByteVector("")); return BaseObject::render(file); } -ByteVector ASF::File::FilePrivate::MetadataObject::guid() const -{ +ByteVector ASF::File::FilePrivate::MetadataObject::guid() const { return metadataGuid; } -void ASF::File::FilePrivate::MetadataObject::parse(ASF::File *file, unsigned int /*size*/) -{ +void ASF::File::FilePrivate::MetadataObject::parse(ASF::File *file, unsigned int /*size*/) { int count = readWORD(file); - while(count--) { + while (count--) { ASF::Attribute attribute; String name = attribute.parse(*file, 1); file->d->tag->addAttribute(name, attribute); } } -ByteVector ASF::File::FilePrivate::MetadataObject::render(ASF::File *file) -{ +ByteVector ASF::File::FilePrivate::MetadataObject::render(ASF::File *file) { data.clear(); data.append(ByteVector::fromShort(attributeData.size(), false)); data.append(attributeData.toByteVector("")); return BaseObject::render(file); } -ByteVector ASF::File::FilePrivate::MetadataLibraryObject::guid() const -{ +ByteVector ASF::File::FilePrivate::MetadataLibraryObject::guid() const { return metadataLibraryGuid; } -void ASF::File::FilePrivate::MetadataLibraryObject::parse(ASF::File *file, unsigned int /*size*/) -{ +void ASF::File::FilePrivate::MetadataLibraryObject::parse(ASF::File *file, unsigned int /*size*/) { int count = readWORD(file); - while(count--) { + while (count--) { ASF::Attribute attribute; String name = attribute.parse(*file, 2); file->d->tag->addAttribute(name, attribute); } } -ByteVector ASF::File::FilePrivate::MetadataLibraryObject::render(ASF::File *file) -{ +ByteVector ASF::File::FilePrivate::MetadataLibraryObject::render(ASF::File *file) { data.clear(); data.append(ByteVector::fromShort(attributeData.size(), false)); data.append(attributeData.toByteVector("")); return BaseObject::render(file); } -ASF::File::FilePrivate::HeaderExtensionObject::HeaderExtensionObject() -{ +ASF::File::FilePrivate::HeaderExtensionObject::HeaderExtensionObject() { objects.setAutoDelete(true); } -ByteVector ASF::File::FilePrivate::HeaderExtensionObject::guid() const -{ +ByteVector ASF::File::FilePrivate::HeaderExtensionObject::guid() const { return headerExtensionGuid; } -void ASF::File::FilePrivate::HeaderExtensionObject::parse(ASF::File *file, unsigned int /*size*/) -{ +void ASF::File::FilePrivate::HeaderExtensionObject::parse(ASF::File *file, unsigned int /*size*/) { file->seek(18, File::Current); long long dataSize = readDWORD(file); long long dataPos = 0; - while(dataPos < dataSize) { + while (dataPos < dataSize) { ByteVector guid = file->readBlock(16); - if(guid.size() != 16) { + if (guid.size() != 16) { file->setValid(false); break; } bool ok; long long size = readQWORD(file, &ok); - if(!ok) { + if (!ok) { file->setValid(false); break; } BaseObject *obj; - if(guid == metadataGuid) { + if (guid == metadataGuid) { file->d->metadataObject = new MetadataObject(); obj = file->d->metadataObject; } - else if(guid == metadataLibraryGuid) { + else if (guid == metadataLibraryGuid) { file->d->metadataLibraryObject = new MetadataLibraryObject(); obj = file->d->metadataLibraryObject; } @@ -406,25 +368,22 @@ void ASF::File::FilePrivate::HeaderExtensionObject::parse(ASF::File *file, unsig } } -ByteVector ASF::File::FilePrivate::HeaderExtensionObject::render(ASF::File *file) -{ +ByteVector ASF::File::FilePrivate::HeaderExtensionObject::render(ASF::File *file) { data.clear(); - for(List::ConstIterator it = objects.begin(); it != objects.end(); ++it) { + for (List::ConstIterator it = objects.begin(); it != objects.end(); ++it) { data.append((*it)->render(file)); } data = ByteVector("\x11\xD2\xD3\xAB\xBA\xA9\xcf\x11\x8E\xE6\x00\xC0\x0C\x20\x53\x65\x06\x00", 18) + ByteVector::fromUInt(data.size(), false) + data; return BaseObject::render(file); } -ByteVector ASF::File::FilePrivate::CodecListObject::guid() const -{ +ByteVector ASF::File::FilePrivate::CodecListObject::guid() const { return codecListGuid; } -void ASF::File::FilePrivate::CodecListObject::parse(ASF::File *file, unsigned int size) -{ +void ASF::File::FilePrivate::CodecListObject::parse(ASF::File *file, unsigned int size) { BaseObject::parse(file, size); - if(data.size() <= 20) { + if (data.size() <= 20) { debug("ASF::File::FilePrivate::CodecListObject::parse() -- data is too short."); return; } @@ -434,9 +393,9 @@ void ASF::File::FilePrivate::CodecListObject::parse(ASF::File *file, unsigned in const int count = data.toUInt(pos, false); pos += 4; - for(int i = 0; i < count; ++i) { + for (int i = 0; i < count; ++i) { - if(pos >= data.size()) + if (pos >= data.size()) break; const CodecType type = static_cast(data.toUShort(pos, false)); @@ -457,7 +416,7 @@ void ASF::File::FilePrivate::CodecListObject::parse(ASF::File *file, unsigned in const int infoLength = data.toUShort(pos, false); pos += 2 + infoLength * 2; - if(type == CodecListObject::Audio) { + if (type == CodecListObject::Audio) { // First audio codec found. const String name(data.mid(namePos, nameLength * 2), String::UTF16LE); @@ -475,8 +434,7 @@ void ASF::File::FilePrivate::CodecListObject::parse(ASF::File *file, unsigned in // static members //////////////////////////////////////////////////////////////////////////////// -bool ASF::File::isSupported(IOStream *stream) -{ +bool ASF::File::isSupported(IOStream *stream) { // An ASF file has to start with the designated GUID. const ByteVector id = Utils::readHeader(stream, 16, false); @@ -487,81 +445,70 @@ bool ASF::File::isSupported(IOStream *stream) // public members //////////////////////////////////////////////////////////////////////////////// -ASF::File::File(FileName file, bool, Properties::ReadStyle) : - Strawberry_TagLib::TagLib::File(file), - d(new FilePrivate()) -{ - if(isOpen()) +ASF::File::File(FileName file, bool, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(file), + d(new FilePrivate()) { + if (isOpen()) read(); } -ASF::File::File(IOStream *stream, bool, Properties::ReadStyle) : - Strawberry_TagLib::TagLib::File(stream), - d(new FilePrivate()) -{ - if(isOpen()) +ASF::File::File(IOStream *stream, bool, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(stream), + d(new FilePrivate()) { + if (isOpen()) read(); } -ASF::File::~File() -{ +ASF::File::~File() { delete d; } -ASF::Tag *ASF::File::tag() const -{ +ASF::Tag *ASF::File::tag() const { return d->tag; } -PropertyMap ASF::File::properties() const -{ +PropertyMap ASF::File::properties() const { return d->tag->properties(); } -void ASF::File::removeUnsupportedProperties(const StringList &properties) -{ +void ASF::File::removeUnsupportedProperties(const StringList &properties) { d->tag->removeUnsupportedProperties(properties); } -PropertyMap ASF::File::setProperties(const PropertyMap &properties) -{ +PropertyMap ASF::File::setProperties(const PropertyMap &properties) { return d->tag->setProperties(properties); } -ASF::Properties *ASF::File::audioProperties() const -{ +ASF::Properties *ASF::File::audioProperties() const { return d->properties; } -bool ASF::File::save() -{ - if(readOnly()) { +bool ASF::File::save() { + if (readOnly()) { debug("ASF::File::save() -- File is read only."); return false; } - if(!isValid()) { + if (!isValid()) { debug("ASF::File::save() -- Trying to save invalid file."); return false; } - if(!d->contentDescriptionObject) { + if (!d->contentDescriptionObject) { d->contentDescriptionObject = new FilePrivate::ContentDescriptionObject(); d->objects.append(d->contentDescriptionObject); } - if(!d->extendedContentDescriptionObject) { + if (!d->extendedContentDescriptionObject) { d->extendedContentDescriptionObject = new FilePrivate::ExtendedContentDescriptionObject(); d->objects.append(d->extendedContentDescriptionObject); } - if(!d->headerExtensionObject) { + if (!d->headerExtensionObject) { d->headerExtensionObject = new FilePrivate::HeaderExtensionObject(); d->objects.append(d->headerExtensionObject); } - if(!d->metadataObject) { + if (!d->metadataObject) { d->metadataObject = new FilePrivate::MetadataObject(); d->headerExtensionObject->objects.append(d->metadataObject); } - if(!d->metadataLibraryObject) { + if (!d->metadataLibraryObject) { d->metadataLibraryObject = new FilePrivate::MetadataLibraryObject(); d->headerExtensionObject->objects.append(d->metadataLibraryObject); } @@ -572,7 +519,7 @@ bool ASF::File::save() const AttributeListMap allAttributes = d->tag->attributeListMap(); - for(AttributeListMap::ConstIterator it = allAttributes.begin(); it != allAttributes.end(); ++it) { + for (AttributeListMap::ConstIterator it = allAttributes.begin(); it != allAttributes.end(); ++it) { const String &name = it->first; const AttributeList &attributes = it->second; @@ -580,17 +527,17 @@ bool ASF::File::save() bool inExtendedContentDescriptionObject = false; bool inMetadataObject = false; - for(AttributeList::ConstIterator jt = attributes.begin(); jt != attributes.end(); ++jt) { + for (AttributeList::ConstIterator jt = attributes.begin(); jt != attributes.end(); ++jt) { const Attribute &attribute = *jt; const bool largeValue = (attribute.dataSize() > 65535); - const bool guid = (attribute.type() == Attribute::GuidType); + const bool guid = (attribute.type() == Attribute::GuidType); - if(!inExtendedContentDescriptionObject && !guid && !largeValue && attribute.language() == 0 && attribute.stream() == 0) { + if (!inExtendedContentDescriptionObject && !guid && !largeValue && attribute.language() == 0 && attribute.stream() == 0) { d->extendedContentDescriptionObject->attributeData.append(attribute.render(name)); inExtendedContentDescriptionObject = true; } - else if(!inMetadataObject && !guid && !largeValue && attribute.language() == 0 && attribute.stream() != 0) { + else if (!inMetadataObject && !guid && !largeValue && attribute.language() == 0 && attribute.stream() != 0) { d->metadataObject->attributeData.append(attribute.render(name, 1)); inMetadataObject = true; } @@ -601,7 +548,7 @@ bool ASF::File::save() } ByteVector data; - for(List::ConstIterator it = d->objects.begin(); it != d->objects.end(); ++it) { + for (List::ConstIterator it = d->objects.begin(); it != d->objects.end(); ++it) { data.append((*it)->render(this)); } @@ -621,12 +568,11 @@ bool ASF::File::save() // private members //////////////////////////////////////////////////////////////////////////////// -void ASF::File::read() -{ - if(!isValid()) +void ASF::File::read() { + if (!isValid()) return; - if(readBlock(16) != headerGuid) { + if (readBlock(16) != headerGuid) { debug("ASF::File::read(): Not an ASF file."); setValid(false); return; @@ -637,58 +583,58 @@ void ASF::File::read() bool ok; d->headerSize = readQWORD(this, &ok); - if(!ok) { + if (!ok) { setValid(false); return; } int numObjects = readDWORD(this, &ok); - if(!ok) { + if (!ok) { setValid(false); return; } seek(2, Current); - FilePrivate::FilePropertiesObject *filePropertiesObject = 0; + FilePrivate::FilePropertiesObject *filePropertiesObject = 0; FilePrivate::StreamPropertiesObject *streamPropertiesObject = 0; - for(int i = 0; i < numObjects; i++) { + for (int i = 0; i < numObjects; i++) { const ByteVector guid = readBlock(16); - if(guid.size() != 16) { + if (guid.size() != 16) { setValid(false); break; } long size = (long)readQWORD(this, &ok); - if(!ok) { + if (!ok) { setValid(false); break; } FilePrivate::BaseObject *obj; - if(guid == filePropertiesGuid) { + if (guid == filePropertiesGuid) { filePropertiesObject = new FilePrivate::FilePropertiesObject(); obj = filePropertiesObject; } - else if(guid == streamPropertiesGuid) { + else if (guid == streamPropertiesGuid) { streamPropertiesObject = new FilePrivate::StreamPropertiesObject(); obj = streamPropertiesObject; } - else if(guid == contentDescriptionGuid) { + else if (guid == contentDescriptionGuid) { d->contentDescriptionObject = new FilePrivate::ContentDescriptionObject(); obj = d->contentDescriptionObject; } - else if(guid == extendedContentDescriptionGuid) { + else if (guid == extendedContentDescriptionGuid) { d->extendedContentDescriptionObject = new FilePrivate::ExtendedContentDescriptionObject(); obj = d->extendedContentDescriptionObject; } - else if(guid == headerExtensionGuid) { + else if (guid == headerExtensionGuid) { d->headerExtensionObject = new FilePrivate::HeaderExtensionObject(); obj = d->headerExtensionObject; } - else if(guid == codecListGuid) { + else if (guid == codecListGuid) { obj = new FilePrivate::CodecListObject(); } else { - if(guid == contentEncryptionGuid || - guid == extendedContentEncryptionGuid || - guid == advancedContentEncryptionGuid) { + if (guid == contentEncryptionGuid || + guid == extendedContentEncryptionGuid || + guid == advancedContentEncryptionGuid) { d->properties->setEncrypted(true); } obj = new FilePrivate::UnknownObject(guid); @@ -697,7 +643,7 @@ void ASF::File::read() d->objects.append(obj); } - if(!filePropertiesObject || !streamPropertiesObject) { + if (!filePropertiesObject || !streamPropertiesObject) { debug("ASF::File::read(): Missing mandatory header objects."); setValid(false); return; diff --git a/3rdparty/taglib/asf/asffile.h b/3rdparty/taglib/asf/asffile.h index 8c978be0c..7a45cbccb 100644 --- a/3rdparty/taglib/asf/asffile.h +++ b/3rdparty/taglib/asf/asffile.h @@ -35,30 +35,28 @@ namespace Strawberry_TagLib { namespace TagLib { - //! An implementation of ASF (WMA) metadata - namespace ASF { +//! An implementation of ASF (WMA) metadata +namespace ASF { - /*! +/*! * This implements and provides an interface for ASF files to the * TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing * the abstract TagLib::File API as well as providing some additional * information specific to ASF files. */ - class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File - { - public: - - /*! +class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File { + public: + /*! * Constructs an ASF file from \a file. * * \note In the current implementation, both \a readProperties and * \a propertiesStyle are ignored. The audio properties are always * read. */ - File(FileName file, bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(FileName file, bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Constructs an ASF file from \a stream. * * \note In the current implementation, both \a readProperties and @@ -68,15 +66,15 @@ namespace TagLib { * \note TagLib will *not* take ownership of the stream, the caller is * responsible for deleting it after the File object. */ - File(IOStream *stream, bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(IOStream *stream, bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Destroys this instance of the File. */ - virtual ~File(); + virtual ~File(); - /*! + /*! * Returns a pointer to the ASF tag of the file. * * ASF::Tag implements the tag interface, so this serves as the @@ -86,55 +84,55 @@ namespace TagLib { * deleted by the user. It will be deleted when the file (object) is * destroyed. */ - virtual Tag *tag() const; + virtual Tag *tag() const; - /*! + /*! * Implements the unified property interface -- export function. */ - PropertyMap properties() const; + PropertyMap properties() const; - /*! + /*! * Removes unsupported properties. Forwards to the actual Tag's * removeUnsupportedProperties() function. */ - void removeUnsupportedProperties(const StringList &properties); + void removeUnsupportedProperties(const StringList &properties); - /*! + /*! * Implements the unified property interface -- import function. */ - PropertyMap setProperties(const PropertyMap &); + PropertyMap setProperties(const PropertyMap &); - /*! + /*! * Returns the ASF audio properties for this file. */ - virtual Properties *audioProperties() const; + virtual Properties *audioProperties() const; - /*! + /*! * Save the file. * * This returns true if the save was successful. */ - virtual bool save(); + virtual bool save(); - /*! + /*! * Returns whether or not the given \a stream can be opened as an ASF * file. * * \note This method is designed to do a quick check. The result may * not necessarily be correct. */ - static bool isSupported(IOStream *stream); + static bool isSupported(IOStream *stream); - private: - void read(); + private: + void read(); - class FilePrivate; - FilePrivate *d; - }; + class FilePrivate; + FilePrivate *d; +}; - } +} // namespace ASF -} -} +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/asf/asfpicture.cpp b/3rdparty/taglib/asf/asfpicture.cpp index ca6446146..de0eb23d7 100644 --- a/3rdparty/taglib/asf/asfpicture.cpp +++ b/3rdparty/taglib/asf/asfpicture.cpp @@ -34,9 +34,8 @@ using namespace Strawberry_TagLib::TagLib; -class ASF::Picture::PicturePrivate : public RefCounter -{ -public: +class ASF::Picture::PicturePrivate : public RefCounter { + public: bool valid; Type type; String mimeType; @@ -48,126 +47,107 @@ public: // Picture class members //////////////////////////////////////////////////////////////////////////////// -ASF::Picture::Picture() : - d(new PicturePrivate()) -{ +ASF::Picture::Picture() : d(new PicturePrivate()) { d->valid = true; } -ASF::Picture::Picture(const Picture& other) : - d(other.d) -{ +ASF::Picture::Picture(const Picture& other) : d(other.d) { d->ref(); } -ASF::Picture::~Picture() -{ - if(d->deref()) +ASF::Picture::~Picture() { + if (d->deref()) delete d; } -bool ASF::Picture::isValid() const -{ +bool ASF::Picture::isValid() const { return d->valid; } -String ASF::Picture::mimeType() const -{ +String ASF::Picture::mimeType() const { return d->mimeType; } -void ASF::Picture::setMimeType(const String &value) -{ +void ASF::Picture::setMimeType(const String& value) { d->mimeType = value; } -ASF::Picture::Type ASF::Picture::type() const -{ +ASF::Picture::Type ASF::Picture::type() const { return d->type; } -void ASF::Picture::setType(const ASF::Picture::Type& t) -{ +void ASF::Picture::setType(const ASF::Picture::Type& t) { d->type = t; } -String ASF::Picture::description() const -{ +String ASF::Picture::description() const { return d->description; } -void ASF::Picture::setDescription(const String &desc) -{ +void ASF::Picture::setDescription(const String& desc) { d->description = desc; } -ByteVector ASF::Picture::picture() const -{ +ByteVector ASF::Picture::picture() const { return d->picture; } -void ASF::Picture::setPicture(const ByteVector &p) -{ +void ASF::Picture::setPicture(const ByteVector& p) { d->picture = p; } -int ASF::Picture::dataSize() const -{ - return - 9 + (d->mimeType.length() + d->description.length()) * 2 + +int ASF::Picture::dataSize() const { + return 9 + (d->mimeType.length() + d->description.length()) * 2 + d->picture.size(); } -ASF::Picture& ASF::Picture::operator=(const ASF::Picture& other) -{ +ASF::Picture& ASF::Picture::operator=(const ASF::Picture& other) { Picture(other).swap(*this); return *this; } -void ASF::Picture::swap(Picture &other) -{ +void ASF::Picture::swap(Picture& other) { using std::swap; swap(d, other.d); } -ByteVector ASF::Picture::render() const -{ - if(!isValid()) +ByteVector ASF::Picture::render() const { + if (!isValid()) return ByteVector(); - return - ByteVector((char)d->type) + + return ByteVector((char)d->type) + ByteVector::fromUInt(d->picture.size(), false) + renderString(d->mimeType) + renderString(d->description) + d->picture; } -void ASF::Picture::parse(const ByteVector& bytes) -{ +void ASF::Picture::parse(const ByteVector& bytes) { d->valid = false; - if(bytes.size() < 9) + if (bytes.size() < 9) return; int pos = 0; - d->type = (Type)bytes[0]; ++pos; - const unsigned int dataLen = bytes.toUInt(pos, false); pos+=4; + d->type = (Type)bytes[0]; + ++pos; + const unsigned int dataLen = bytes.toUInt(pos, false); + pos += 4; const ByteVector nullStringTerminator(2, 0); int endPos = bytes.find(nullStringTerminator, pos, 2); - if(endPos < 0) + if (endPos < 0) return; d->mimeType = String(bytes.mid(pos, endPos - pos), String::UTF16LE); - pos = endPos+2; + pos = endPos + 2; endPos = bytes.find(nullStringTerminator, pos, 2); - if(endPos < 0) + if (endPos < 0) return; d->description = String(bytes.mid(pos, endPos - pos), String::UTF16LE); - pos = endPos+2; + pos = endPos + 2; - if(dataLen + pos != bytes.size()) + if (dataLen + pos != bytes.size()) return; d->picture = bytes.mid(pos, dataLen); @@ -175,8 +155,7 @@ void ASF::Picture::parse(const ByteVector& bytes) return; } -ASF::Picture ASF::Picture::fromInvalid() -{ +ASF::Picture ASF::Picture::fromInvalid() { Picture ret; ret.d->valid = false; return ret; diff --git a/3rdparty/taglib/asf/asfpicture.h b/3rdparty/taglib/asf/asfpicture.h index c41f4289a..07fa284df 100644 --- a/3rdparty/taglib/asf/asfpicture.h +++ b/3rdparty/taglib/asf/asfpicture.h @@ -32,14 +32,12 @@ #include "attachedpictureframe.h" namespace Strawberry_TagLib { -namespace TagLib -{ - namespace ASF - { +namespace TagLib { +namespace ASF { - //! An ASF attached picture interface implementation +//! An ASF attached picture interface implementation - /*! +/*! * This is an implementation of ASF attached pictures interface. Pictures may be * included in attributes, one per WM/Picture attribute (but there may be multiple WM/Picture * attribute in a single tag). These pictures are usually in either JPEG or @@ -47,136 +45,135 @@ namespace TagLib * \see Attribute::toPicture() * \see Attribute::Attribute(const Picture& picture) */ - class TAGLIB_EXPORT Picture { - public: - - /*! +class TAGLIB_EXPORT Picture { + public: + /*! * This describes the function or content of the picture. */ - enum Type { - //! A type not enumerated below - Other = 0x00, - //! 32x32 PNG image that should be used as the file icon - FileIcon = 0x01, - //! File icon of a different size or format - OtherFileIcon = 0x02, - //! Front cover image of the album - FrontCover = 0x03, - //! Back cover image of the album - BackCover = 0x04, - //! Inside leaflet page of the album - LeafletPage = 0x05, - //! Image from the album itself - Media = 0x06, - //! Picture of the lead artist or soloist - LeadArtist = 0x07, - //! Picture of the artist or performer - Artist = 0x08, - //! Picture of the conductor - Conductor = 0x09, - //! Picture of the band or orchestra - Band = 0x0A, - //! Picture of the composer - Composer = 0x0B, - //! Picture of the lyricist or text writer - Lyricist = 0x0C, - //! Picture of the recording location or studio - RecordingLocation = 0x0D, - //! Picture of the artists during recording - DuringRecording = 0x0E, - //! Picture of the artists during performance - DuringPerformance = 0x0F, - //! Picture from a movie or video related to the track - MovieScreenCapture = 0x10, - //! Picture of a large, coloured fish - ColouredFish = 0x11, - //! Illustration related to the track - Illustration = 0x12, - //! Logo of the band or performer - BandLogo = 0x13, - //! Logo of the publisher (record company) - PublisherLogo = 0x14 - }; + enum Type { + //! A type not enumerated below + Other = 0x00, + //! 32x32 PNG image that should be used as the file icon + FileIcon = 0x01, + //! File icon of a different size or format + OtherFileIcon = 0x02, + //! Front cover image of the album + FrontCover = 0x03, + //! Back cover image of the album + BackCover = 0x04, + //! Inside leaflet page of the album + LeafletPage = 0x05, + //! Image from the album itself + Media = 0x06, + //! Picture of the lead artist or soloist + LeadArtist = 0x07, + //! Picture of the artist or performer + Artist = 0x08, + //! Picture of the conductor + Conductor = 0x09, + //! Picture of the band or orchestra + Band = 0x0A, + //! Picture of the composer + Composer = 0x0B, + //! Picture of the lyricist or text writer + Lyricist = 0x0C, + //! Picture of the recording location or studio + RecordingLocation = 0x0D, + //! Picture of the artists during recording + DuringRecording = 0x0E, + //! Picture of the artists during performance + DuringPerformance = 0x0F, + //! Picture from a movie or video related to the track + MovieScreenCapture = 0x10, + //! Picture of a large, coloured fish + ColouredFish = 0x11, + //! Illustration related to the track + Illustration = 0x12, + //! Logo of the band or performer + BandLogo = 0x13, + //! Logo of the publisher (record company) + PublisherLogo = 0x14 + }; - /*! + /*! * Constructs an empty picture. */ - Picture(); + Picture(); - /*! + /*! * Construct an picture as a copy of \a other. */ - Picture(const Picture& other); + Picture(const Picture& other); - /*! + /*! * Destroys the picture. */ - virtual ~Picture(); + virtual ~Picture(); - /*! + /*! * Copies the contents of \a other into this picture. */ - Picture& operator=(const Picture& other); + Picture& operator=(const Picture& other); - /*! + /*! * Exchanges the content of the Picture by the content of \a other. */ - void swap(Picture &other); + void swap(Picture& other); - /*! + /*! * Returns true if Picture stores valid picture */ - bool isValid() const; + bool isValid() const; - /*! + /*! * Returns the mime type of the image. This should in most cases be * "image/png" or "image/jpeg". * \see setMimeType(const String &) * \see picture() * \see setPicture(const ByteArray&) */ - String mimeType() const; + String mimeType() const; - /*! + /*! * Sets the mime type of the image. This should in most cases be * "image/png" or "image/jpeg". * \see setMimeType(const String &) * \see picture() * \see setPicture(const ByteArray&) */ - void setMimeType(const String &value); + void setMimeType(const String& value); - /*! + /*! * Returns the type of the image. * * \see Type * \see setType() */ - Type type() const; + Type type() const; - /*! + /*! * Sets the type for the image. * * \see Type * \see type() */ - void setType(const ASF::Picture::Type& t); + void setType(const ASF::Picture::Type& t); - /*! + /*! * Returns a text description of the image. * * \see setDescription() */ - String description() const; + String description() const; - /*! + /*! * Sets a textual description of the image to \a desc. * * \see description() */ - void setDescription(const String &desc); + void setDescription(const String& desc); - /*! + /*! * Returns the image data as a ByteVector. * * \note ByteVector has a data() method that returns a const char * which @@ -185,9 +182,9 @@ namespace TagLib * \see setPicture() * \see mimeType() */ - ByteVector picture() const; + ByteVector picture() const; - /*! + /*! * Sets the image data to \a p. \a p should be of the type specified in * this frame's mime-type specification. * @@ -195,30 +192,30 @@ namespace TagLib * \see mimeType() * \see setMimeType() */ - void setPicture(const ByteVector &p); + void setPicture(const ByteVector& p); - /*! + /*! * Returns picture as binary raw data \a value */ - ByteVector render() const; + ByteVector render() const; - /*! + /*! * Returns picture as binary raw data \a value */ - int dataSize() const; + int dataSize() const; #ifndef DO_NOT_DOCUMENT - /* THIS IS PRIVATE, DON'T TOUCH IT! */ - void parse(const ByteVector& ); - static Picture fromInvalid(); + /* THIS IS PRIVATE, DON'T TOUCH IT! */ + void parse(const ByteVector&); + static Picture fromInvalid(); #endif - private: - class PicturePrivate; - PicturePrivate *d; - }; - } -} -} + private: + class PicturePrivate; + PicturePrivate* d; +}; +} // namespace ASF +} // namespace TagLib +} // namespace Strawberry_TagLib -#endif // ASFPICTURE_H +#endif // ASFPICTURE_H diff --git a/3rdparty/taglib/asf/asfproperties.cpp b/3rdparty/taglib/asf/asfproperties.cpp index fd00096b3..843da75e9 100644 --- a/3rdparty/taglib/asf/asfproperties.cpp +++ b/3rdparty/taglib/asf/asfproperties.cpp @@ -29,17 +29,15 @@ using namespace Strawberry_TagLib::TagLib; -class ASF::Properties::PropertiesPrivate -{ -public: - PropertiesPrivate() : - length(0), - bitrate(0), - sampleRate(0), - channels(0), - bitsPerSample(0), - codec(ASF::Properties::Unknown), - encrypted(false) {} +class ASF::Properties::PropertiesPrivate { + public: + PropertiesPrivate() : length(0), + bitrate(0), + sampleRate(0), + channels(0), + bitsPerSample(0), + codec(ASF::Properties::Unknown), + encrypted(false) {} int length; int bitrate; @@ -56,69 +54,55 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -ASF::Properties::Properties() : - AudioProperties(AudioProperties::Average), - d(new PropertiesPrivate()) -{ +ASF::Properties::Properties() : AudioProperties(AudioProperties::Average), + d(new PropertiesPrivate()) { } -ASF::Properties::~Properties() -{ +ASF::Properties::~Properties() { delete d; } -int ASF::Properties::length() const -{ +int ASF::Properties::length() const { return lengthInSeconds(); } -int ASF::Properties::lengthInSeconds() const -{ +int ASF::Properties::lengthInSeconds() const { return d->length / 1000; } -int ASF::Properties::lengthInMilliseconds() const -{ +int ASF::Properties::lengthInMilliseconds() const { return d->length; } -int ASF::Properties::bitrate() const -{ +int ASF::Properties::bitrate() const { return d->bitrate; } -int ASF::Properties::sampleRate() const -{ +int ASF::Properties::sampleRate() const { return d->sampleRate; } -int ASF::Properties::channels() const -{ +int ASF::Properties::channels() const { return d->channels; } -int ASF::Properties::bitsPerSample() const -{ +int ASF::Properties::bitsPerSample() const { return d->bitsPerSample; } -ASF::Properties::Codec ASF::Properties::codec() const -{ +ASF::Properties::Codec ASF::Properties::codec() const { return d->codec; } -String ASF::Properties::codecName() const -{ +String ASF::Properties::codecName() const { return d->codecName; } -String ASF::Properties::codecDescription() const -{ +String ASF::Properties::codecDescription() const { return d->codecDescription; } -bool ASF::Properties::isEncrypted() const -{ +bool ASF::Properties::isEncrypted() const { return d->encrypted; } @@ -126,69 +110,58 @@ bool ASF::Properties::isEncrypted() const // private members //////////////////////////////////////////////////////////////////////////////// -void ASF::Properties::setLength(int /*length*/) -{ +void ASF::Properties::setLength(int /*length*/) { debug("ASF::Properties::setLength() -- This method is deprecated. Do not use."); } -void ASF::Properties::setLengthInMilliseconds(int value) -{ +void ASF::Properties::setLengthInMilliseconds(int value) { d->length = value; } -void ASF::Properties::setBitrate(int value) -{ +void ASF::Properties::setBitrate(int value) { d->bitrate = value; } -void ASF::Properties::setSampleRate(int value) -{ +void ASF::Properties::setSampleRate(int value) { d->sampleRate = value; } -void ASF::Properties::setChannels(int value) -{ +void ASF::Properties::setChannels(int value) { d->channels = value; } -void ASF::Properties::setBitsPerSample(int value) -{ +void ASF::Properties::setBitsPerSample(int value) { d->bitsPerSample = value; } -void ASF::Properties::setCodec(int value) -{ - switch(value) - { - case 0x0160: - d->codec = WMA1; - break; - case 0x0161: - d->codec = WMA2; - break; - case 0x0162: - d->codec = WMA9Pro; - break; - case 0x0163: - d->codec = WMA9Lossless; - break; - default: - d->codec = Unknown; - break; +void ASF::Properties::setCodec(int value) { + switch (value) { + case 0x0160: + d->codec = WMA1; + break; + case 0x0161: + d->codec = WMA2; + break; + case 0x0162: + d->codec = WMA9Pro; + break; + case 0x0163: + d->codec = WMA9Lossless; + break; + default: + d->codec = Unknown; + break; } } -void ASF::Properties::setCodecName(const String &value) -{ +void ASF::Properties::setCodecName(const String &value) { d->codecName = value; } -void ASF::Properties::setCodecDescription(const String &value) -{ +void ASF::Properties::setCodecDescription(const String &value) { d->codecDescription = value; } -void ASF::Properties::setEncrypted(bool value) -{ +void ASF::Properties::setEncrypted(bool value) { d->encrypted = value; } diff --git a/3rdparty/taglib/asf/asfproperties.h b/3rdparty/taglib/asf/asfproperties.h index 74ac529fa..29100d0d7 100644 --- a/3rdparty/taglib/asf/asfproperties.h +++ b/3rdparty/taglib/asf/asfproperties.h @@ -33,55 +33,52 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace ASF { +namespace ASF { - //! An implementation of ASF audio properties - class TAGLIB_EXPORT Properties : public AudioProperties - { - public: - - /*! +//! An implementation of ASF audio properties +class TAGLIB_EXPORT Properties : public AudioProperties { + public: + /*! * Audio codec types can be used in ASF file. */ - enum Codec - { - /*! + enum Codec { + /*! * Couldn't detect the codec. */ - Unknown = 0, + Unknown = 0, - /*! + /*! * Windows Media Audio 1 */ - WMA1, + WMA1, - /*! + /*! * Windows Media Audio 2 or above */ - WMA2, + WMA2, - /*! + /*! * Windows Media Audio 9 Professional */ - WMA9Pro, + WMA9Pro, - /*! + /*! * Windows Media Audio 9 Lossless */ - WMA9Lossless, - }; + WMA9Lossless, + }; - /*! + /*! * Creates an instance of ASF::Properties. */ - Properties(); + Properties(); - /*! + /*! * Destroys this ASF::Properties instance. */ - virtual ~Properties(); + virtual ~Properties(); - /*! + /*! * Returns the length of the file in seconds. The length is rounded down to * the nearest whole second. * @@ -89,63 +86,63 @@ namespace TagLib { * * \deprecated */ - virtual int length() const; + virtual int length() const; - /*! + /*! * Returns the length of the file in seconds. The length is rounded down to * the nearest whole second. * * \see lengthInMilliseconds() */ - // BIC: make virtual - int lengthInSeconds() const; + // BIC: make virtual + int lengthInSeconds() const; - /*! + /*! * Returns the length of the file in milliseconds. * * \see lengthInSeconds() */ - // BIC: make virtual - int lengthInMilliseconds() const; + // BIC: make virtual + int lengthInMilliseconds() const; - /*! + /*! * Returns the average bit rate of the file in kb/s. */ - virtual int bitrate() const; + virtual int bitrate() const; - /*! + /*! * Returns the sample rate in Hz. */ - virtual int sampleRate() const; + virtual int sampleRate() const; - /*! + /*! * Returns the number of audio channels. */ - virtual int channels() const; + virtual int channels() const; - /*! + /*! * Returns the number of bits per audio sample. */ - int bitsPerSample() const; + int bitsPerSample() const; - /*! + /*! * Returns the codec used in the file. * * \see codecName() * \see codecDescription() */ - Codec codec() const; + Codec codec() const; - /*! + /*! * Returns the concrete codec name, for example "Windows Media Audio 9.1" * used in the file if available, otherwise an empty string. * * \see codec() * \see codecDescription() */ - String codecName() const; + String codecName() const; - /*! + /*! * Returns the codec description, typically contains the encoder settings, * for example "VBR Quality 50, 44kHz, stereo 1-pass VBR" if available, * otherwise an empty string. @@ -153,36 +150,36 @@ namespace TagLib { * \see codec() * \see codecName() */ - String codecDescription() const; + String codecDescription() const; - /*! + /*! * Returns whether or not the file is encrypted. */ - bool isEncrypted() const; + bool isEncrypted() const; #ifndef DO_NOT_DOCUMENT - // deprecated - void setLength(int value); + // deprecated + void setLength(int value); - void setLengthInMilliseconds(int value); - void setBitrate(int value); - void setSampleRate(int value); - void setChannels(int value); - void setBitsPerSample(int value); - void setCodec(int value); - void setCodecName(const String &value); - void setCodecDescription(const String &value); - void setEncrypted(bool value); + void setLengthInMilliseconds(int value); + void setBitrate(int value); + void setSampleRate(int value); + void setChannels(int value); + void setBitsPerSample(int value); + void setCodec(int value); + void setCodecName(const String &value); + void setCodecDescription(const String &value); + void setEncrypted(bool value); #endif - private: - class PropertiesPrivate; - PropertiesPrivate *d; - }; + private: + class PropertiesPrivate; + PropertiesPrivate *d; +}; - } +} // namespace ASF -} -} +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/asf/asftag.cpp b/3rdparty/taglib/asf/asftag.cpp index b2c060382..7f7ca7977 100644 --- a/3rdparty/taglib/asf/asftag.cpp +++ b/3rdparty/taglib/asf/asftag.cpp @@ -28,9 +28,8 @@ using namespace Strawberry_TagLib::TagLib; -class ASF::Tag::TagPrivate -{ -public: +class ASF::Tag::TagPrivate { + public: String title; String artist; String copyright; @@ -39,162 +38,133 @@ public: AttributeListMap attributeListMap; }; -ASF::Tag::Tag() : - Strawberry_TagLib::TagLib::Tag(), - d(new TagPrivate()) -{ +ASF::Tag::Tag() : Strawberry_TagLib::TagLib::Tag(), + d(new TagPrivate()) { } -ASF::Tag::~Tag() -{ +ASF::Tag::~Tag() { delete d; } -String ASF::Tag::title() const -{ +String ASF::Tag::title() const { return d->title; } -String ASF::Tag::artist() const -{ +String ASF::Tag::artist() const { return d->artist; } -String ASF::Tag::album() const -{ - if(d->attributeListMap.contains("WM/AlbumTitle")) +String ASF::Tag::album() const { + if (d->attributeListMap.contains("WM/AlbumTitle")) return d->attributeListMap["WM/AlbumTitle"][0].toString(); return String(); } -String ASF::Tag::copyright() const -{ +String ASF::Tag::copyright() const { return d->copyright; } -String ASF::Tag::comment() const -{ +String ASF::Tag::comment() const { return d->comment; } -String ASF::Tag::rating() const -{ +String ASF::Tag::rating() const { return d->rating; } -unsigned int ASF::Tag::year() const -{ - if(d->attributeListMap.contains("WM/Year")) +unsigned int ASF::Tag::year() const { + if (d->attributeListMap.contains("WM/Year")) return d->attributeListMap["WM/Year"][0].toString().toInt(); return 0; } -unsigned int ASF::Tag::track() const -{ - if(d->attributeListMap.contains("WM/TrackNumber")) { +unsigned int ASF::Tag::track() const { + if (d->attributeListMap.contains("WM/TrackNumber")) { const ASF::Attribute attr = d->attributeListMap["WM/TrackNumber"][0]; - if(attr.type() == ASF::Attribute::DWordType) + if (attr.type() == ASF::Attribute::DWordType) return attr.toUInt(); else return attr.toString().toInt(); } - if(d->attributeListMap.contains("WM/Track")) + if (d->attributeListMap.contains("WM/Track")) return d->attributeListMap["WM/Track"][0].toUInt(); return 0; } -String ASF::Tag::genre() const -{ - if(d->attributeListMap.contains("WM/Genre")) +String ASF::Tag::genre() const { + if (d->attributeListMap.contains("WM/Genre")) return d->attributeListMap["WM/Genre"][0].toString(); return String(); } -void ASF::Tag::setTitle(const String &value) -{ +void ASF::Tag::setTitle(const String &value) { d->title = value; } -void ASF::Tag::setArtist(const String &value) -{ +void ASF::Tag::setArtist(const String &value) { d->artist = value; } -void ASF::Tag::setCopyright(const String &value) -{ +void ASF::Tag::setCopyright(const String &value) { d->copyright = value; } -void ASF::Tag::setComment(const String &value) -{ +void ASF::Tag::setComment(const String &value) { d->comment = value; } -void ASF::Tag::setRating(const String &value) -{ +void ASF::Tag::setRating(const String &value) { d->rating = value; } -void ASF::Tag::setAlbum(const String &value) -{ +void ASF::Tag::setAlbum(const String &value) { setAttribute("WM/AlbumTitle", value); } -void ASF::Tag::setGenre(const String &value) -{ +void ASF::Tag::setGenre(const String &value) { setAttribute("WM/Genre", value); } -void ASF::Tag::setYear(unsigned int value) -{ +void ASF::Tag::setYear(unsigned int value) { setAttribute("WM/Year", String::number(value)); } -void ASF::Tag::setTrack(unsigned int value) -{ +void ASF::Tag::setTrack(unsigned int value) { setAttribute("WM/TrackNumber", String::number(value)); } -ASF::AttributeListMap& ASF::Tag::attributeListMap() -{ +ASF::AttributeListMap &ASF::Tag::attributeListMap() { return d->attributeListMap; } -const ASF::AttributeListMap &ASF::Tag::attributeListMap() const -{ +const ASF::AttributeListMap &ASF::Tag::attributeListMap() const { return d->attributeListMap; } -bool ASF::Tag::contains(const String &key) const -{ +bool ASF::Tag::contains(const String &key) const { return d->attributeListMap.contains(key); } -void ASF::Tag::removeItem(const String &key) -{ +void ASF::Tag::removeItem(const String &key) { d->attributeListMap.erase(key); } -ASF::AttributeList ASF::Tag::attribute(const String &name) const -{ +ASF::AttributeList ASF::Tag::attribute(const String &name) const { return d->attributeListMap[name]; } -void ASF::Tag::setAttribute(const String &name, const Attribute &attribute) -{ +void ASF::Tag::setAttribute(const String &name, const Attribute &attribute) { AttributeList value; value.append(attribute); d->attributeListMap.insert(name, value); } -void ASF::Tag::setAttribute(const String &name, const AttributeList &values) -{ +void ASF::Tag::setAttribute(const String &name, const AttributeList &values) { d->attributeListMap.insert(name, values); } -void ASF::Tag::addAttribute(const String &name, const Attribute &attribute) -{ - if(d->attributeListMap.contains(name)) { +void ASF::Tag::addAttribute(const String &name, const Attribute &attribute) { + if (d->attributeListMap.contains(name)) { d->attributeListMap[name].append(attribute); } else { @@ -202,95 +172,91 @@ void ASF::Tag::addAttribute(const String &name, const Attribute &attribute) } } -bool ASF::Tag::isEmpty() const -{ +bool ASF::Tag::isEmpty() const { return Strawberry_TagLib::TagLib::Tag::isEmpty() && - copyright().isEmpty() && - rating().isEmpty() && - d->attributeListMap.isEmpty(); + copyright().isEmpty() && + rating().isEmpty() && + d->attributeListMap.isEmpty(); } -namespace -{ - const char *keyTranslation[][2] = { - { "WM/AlbumTitle", "ALBUM" }, - { "WM/AlbumArtist", "ALBUMARTIST" }, - { "WM/Composer", "COMPOSER" }, - { "WM/Writer", "WRITER" }, - { "WM/Conductor", "CONDUCTOR" }, - { "WM/ModifiedBy", "REMIXER" }, - { "WM/Year", "DATE" }, - { "WM/OriginalReleaseYear", "ORIGINALDATE" }, - { "WM/Producer", "PRODUCER" }, - { "WM/ContentGroupDescription", "GROUPING" }, - { "WM/SubTitle", "SUBTITLE" }, - { "WM/SetSubTitle", "DISCSUBTITLE" }, - { "WM/TrackNumber", "TRACKNUMBER" }, - { "WM/PartOfSet", "DISCNUMBER" }, - { "WM/Genre", "GENRE" }, - { "WM/BeatsPerMinute", "BPM" }, - { "WM/Mood", "MOOD" }, - { "WM/ISRC", "ISRC" }, - { "WM/Lyrics", "LYRICS" }, - { "WM/Media", "MEDIA" }, - { "WM/Publisher", "LABEL" }, - { "WM/CatalogNo", "CATALOGNUMBER" }, - { "WM/Barcode", "BARCODE" }, - { "WM/EncodedBy", "ENCODEDBY" }, - { "WM/AlbumSortOrder", "ALBUMSORT" }, - { "WM/AlbumArtistSortOrder", "ALBUMARTISTSORT" }, - { "WM/ArtistSortOrder", "ARTISTSORT" }, - { "WM/TitleSortOrder", "TITLESORT" }, - { "WM/Script", "SCRIPT" }, - { "WM/Language", "LANGUAGE" }, - { "MusicBrainz/Track Id", "MUSICBRAINZ_TRACKID" }, - { "MusicBrainz/Artist Id", "MUSICBRAINZ_ARTISTID" }, - { "MusicBrainz/Album Id", "MUSICBRAINZ_ALBUMID" }, - { "MusicBrainz/Album Artist Id", "MUSICBRAINZ_ALBUMARTISTID" }, - { "MusicBrainz/Release Group Id", "MUSICBRAINZ_RELEASEGROUPID" }, - { "MusicBrainz/Work Id", "MUSICBRAINZ_WORKID" }, - { "MusicIP/PUID", "MUSICIP_PUID" }, - { "Acoustid/Id", "ACOUSTID_ID" }, - { "Acoustid/Fingerprint", "ACOUSTID_FINGERPRINT" }, - }; - const size_t keyTranslationSize = sizeof(keyTranslation) / sizeof(keyTranslation[0]); +namespace { +const char *keyTranslation[][2] = { + { "WM/AlbumTitle", "ALBUM" }, + { "WM/AlbumArtist", "ALBUMARTIST" }, + { "WM/Composer", "COMPOSER" }, + { "WM/Writer", "WRITER" }, + { "WM/Conductor", "CONDUCTOR" }, + { "WM/ModifiedBy", "REMIXER" }, + { "WM/Year", "DATE" }, + { "WM/OriginalReleaseYear", "ORIGINALDATE" }, + { "WM/Producer", "PRODUCER" }, + { "WM/ContentGroupDescription", "GROUPING" }, + { "WM/SubTitle", "SUBTITLE" }, + { "WM/SetSubTitle", "DISCSUBTITLE" }, + { "WM/TrackNumber", "TRACKNUMBER" }, + { "WM/PartOfSet", "DISCNUMBER" }, + { "WM/Genre", "GENRE" }, + { "WM/BeatsPerMinute", "BPM" }, + { "WM/Mood", "MOOD" }, + { "WM/ISRC", "ISRC" }, + { "WM/Lyrics", "LYRICS" }, + { "WM/Media", "MEDIA" }, + { "WM/Publisher", "LABEL" }, + { "WM/CatalogNo", "CATALOGNUMBER" }, + { "WM/Barcode", "BARCODE" }, + { "WM/EncodedBy", "ENCODEDBY" }, + { "WM/AlbumSortOrder", "ALBUMSORT" }, + { "WM/AlbumArtistSortOrder", "ALBUMARTISTSORT" }, + { "WM/ArtistSortOrder", "ARTISTSORT" }, + { "WM/TitleSortOrder", "TITLESORT" }, + { "WM/Script", "SCRIPT" }, + { "WM/Language", "LANGUAGE" }, + { "MusicBrainz/Track Id", "MUSICBRAINZ_TRACKID" }, + { "MusicBrainz/Artist Id", "MUSICBRAINZ_ARTISTID" }, + { "MusicBrainz/Album Id", "MUSICBRAINZ_ALBUMID" }, + { "MusicBrainz/Album Artist Id", "MUSICBRAINZ_ALBUMARTISTID" }, + { "MusicBrainz/Release Group Id", "MUSICBRAINZ_RELEASEGROUPID" }, + { "MusicBrainz/Work Id", "MUSICBRAINZ_WORKID" }, + { "MusicIP/PUID", "MUSICIP_PUID" }, + { "Acoustid/Id", "ACOUSTID_ID" }, + { "Acoustid/Fingerprint", "ACOUSTID_FINGERPRINT" }, +}; +const size_t keyTranslationSize = sizeof(keyTranslation) / sizeof(keyTranslation[0]); - String translateKey(const String &key) - { - for(size_t i = 0; i < keyTranslationSize; ++i) { - if(key == keyTranslation[i][0]) - return keyTranslation[i][1]; - } - - return String(); +String translateKey(const String &key) { + for (size_t i = 0; i < keyTranslationSize; ++i) { + if (key == keyTranslation[i][0]) + return keyTranslation[i][1]; } -} -PropertyMap ASF::Tag::properties() const -{ + return String(); +} +} // namespace + +PropertyMap ASF::Tag::properties() const { PropertyMap props; - if(!d->title.isEmpty()) { + if (!d->title.isEmpty()) { props["TITLE"] = d->title; } - if(!d->artist.isEmpty()) { + if (!d->artist.isEmpty()) { props["ARTIST"] = d->artist; } - if(!d->copyright.isEmpty()) { + if (!d->copyright.isEmpty()) { props["COPYRIGHT"] = d->copyright; } - if(!d->comment.isEmpty()) { + if (!d->comment.isEmpty()) { props["COMMENT"] = d->comment; } ASF::AttributeListMap::ConstIterator it = d->attributeListMap.begin(); - for(; it != d->attributeListMap.end(); ++it) { + for (; it != d->attributeListMap.end(); ++it) { const String key = translateKey(it->first); - if(!key.isEmpty()) { + if (!key.isEmpty()) { AttributeList::ConstIterator it2 = it->second.begin(); - for(; it2 != it->second.end(); ++it2) { - if(key == "TRACKNUMBER") { - if(it2->type() == ASF::Attribute::DWordType) + for (; it2 != it->second.end(); ++it2) { + if (key == "TRACKNUMBER") { + if (it2->type() == ASF::Attribute::DWordType) props.insert(key, String::number(it2->toUInt())); else props.insert(key, it2->toString()); @@ -307,37 +273,35 @@ PropertyMap ASF::Tag::properties() const return props; } -void ASF::Tag::removeUnsupportedProperties(const StringList &props) -{ +void ASF::Tag::removeUnsupportedProperties(const StringList &props) { StringList::ConstIterator it = props.begin(); - for(; it != props.end(); ++it) + for (; it != props.end(); ++it) d->attributeListMap.erase(*it); } -PropertyMap ASF::Tag::setProperties(const PropertyMap &props) -{ +PropertyMap ASF::Tag::setProperties(const PropertyMap &props) { static Map reverseKeyMap; - if(reverseKeyMap.isEmpty()) { + if (reverseKeyMap.isEmpty()) { int numKeys = sizeof(keyTranslation) / sizeof(keyTranslation[0]); - for(int i = 0; i < numKeys; i++) { + for (int i = 0; i < numKeys; i++) { reverseKeyMap[keyTranslation[i][1]] = keyTranslation[i][0]; } } PropertyMap origProps = properties(); PropertyMap::ConstIterator it = origProps.begin(); - for(; it != origProps.end(); ++it) { - if(!props.contains(it->first) || props[it->first].isEmpty()) { - if(it->first == "TITLE") { + for (; it != origProps.end(); ++it) { + if (!props.contains(it->first) || props[it->first].isEmpty()) { + if (it->first == "TITLE") { d->title.clear(); } - else if(it->first == "ARTIST") { + else if (it->first == "ARTIST") { d->artist.clear(); } - else if(it->first == "COMMENT") { + else if (it->first == "COMMENT") { d->comment.clear(); } - else if(it->first == "COPYRIGHT") { + else if (it->first == "COPYRIGHT") { d->copyright.clear(); } else { @@ -348,25 +312,25 @@ PropertyMap ASF::Tag::setProperties(const PropertyMap &props) PropertyMap ignoredProps; it = props.begin(); - for(; it != props.end(); ++it) { - if(reverseKeyMap.contains(it->first)) { + for (; it != props.end(); ++it) { + if (reverseKeyMap.contains(it->first)) { String name = reverseKeyMap[it->first]; removeItem(name); StringList::ConstIterator it2 = it->second.begin(); - for(; it2 != it->second.end(); ++it2) { + for (; it2 != it->second.end(); ++it2) { addAttribute(name, *it2); } } - else if(it->first == "TITLE") { + else if (it->first == "TITLE") { d->title = it->second.toString(); } - else if(it->first == "ARTIST") { + else if (it->first == "ARTIST") { d->artist = it->second.toString(); } - else if(it->first == "COMMENT") { + else if (it->first == "COMMENT") { d->comment = it->second.toString(); } - else if(it->first == "COPYRIGHT") { + else if (it->first == "COPYRIGHT") { d->copyright = it->second.toString(); } else { diff --git a/3rdparty/taglib/asf/asftag.h b/3rdparty/taglib/asf/asftag.h index aff74be30..8a8786e6a 100644 --- a/3rdparty/taglib/asf/asftag.h +++ b/3rdparty/taglib/asf/asftag.h @@ -35,178 +35,176 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace ASF { +namespace ASF { - typedef List AttributeList; - typedef Map AttributeListMap; +typedef List AttributeList; +typedef Map AttributeListMap; - class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag { +class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag { - friend class File; + friend class File; - public: + public: + Tag(); - Tag(); + virtual ~Tag(); - virtual ~Tag(); - - /*! + /*! * Returns the track name. */ - virtual String title() const; + virtual String title() const; - /*! + /*! * Returns the artist name. */ - virtual String artist() const; + virtual String artist() const; - /*! + /*! * Returns the album name; if no album name is present in the tag * String::null will be returned. */ - virtual String album() const; + virtual String album() const; - /*! + /*! * Returns the track comment. */ - virtual String comment() const; + virtual String comment() const; - /*! + /*! * Returns the genre name; if no genre is present in the tag String::null * will be returned. */ - virtual String genre() const; + virtual String genre() const; - /*! + /*! * Returns the rating. */ - virtual String rating() const; + virtual String rating() const; - /*! + /*! * Returns the genre name; if no genre is present in the tag String::null * will be returned. */ - virtual String copyright() const; + virtual String copyright() const; - /*! + /*! * Returns the year; if there is no year set, this will return 0. */ - virtual unsigned int year() const; + virtual unsigned int year() const; - /*! + /*! * Returns the track number; if there is no track number set, this will * return 0. */ - virtual unsigned int track() const; + virtual unsigned int track() const; - /*! + /*! * Sets the title to \a s. */ - virtual void setTitle(const String &s); + virtual void setTitle(const String &s); - /*! + /*! * Sets the artist to \a s. */ - virtual void setArtist(const String &s); + virtual void setArtist(const String &s); - /*! + /*! * Sets the album to \a s. If \a s is String::null then this value will be * cleared. */ - virtual void setAlbum(const String &s); + virtual void setAlbum(const String &s); - /*! + /*! * Sets the comment to \a s. */ - virtual void setComment(const String &s); + virtual void setComment(const String &s); - /*! + /*! * Sets the rating to \a s. */ - virtual void setRating(const String &s); + virtual void setRating(const String &s); - /*! + /*! * Sets the copyright to \a s. */ - virtual void setCopyright(const String &s); + virtual void setCopyright(const String &s); - /*! + /*! * Sets the genre to \a s. */ - virtual void setGenre(const String &s); + virtual void setGenre(const String &s); - /*! + /*! * Sets the year to \a i. If \a s is 0 then this value will be cleared. */ - virtual void setYear(unsigned int i); + virtual void setYear(unsigned int i); - /*! + /*! * Sets the track to \a i. If \a s is 0 then this value will be cleared. */ - virtual void setTrack(unsigned int i); + virtual void setTrack(unsigned int i); - /*! + /*! * Returns true if the tag does not contain any data. This should be * reimplemented in subclasses that provide more than the basic tagging * abilities in this class. */ - virtual bool isEmpty() const; + virtual bool isEmpty() const; - /*! + /*! * \deprecated */ - AttributeListMap &attributeListMap(); + AttributeListMap &attributeListMap(); - /*! + /*! * Returns a reference to the item list map. This is an AttributeListMap of * all of the items in the tag. */ - // BIC: return by value - const AttributeListMap &attributeListMap() const; + // BIC: return by value + const AttributeListMap &attributeListMap() const; - /*! + /*! * \return True if a value for \a attribute is currently set. */ - bool contains(const String &name) const; + bool contains(const String &name) const; - /*! + /*! * Removes the \a key attribute from the tag */ - void removeItem(const String &name); + void removeItem(const String &name); - /*! + /*! * \return The list of values for the key \a name, or an empty list if no * values have been set. */ - AttributeList attribute(const String &name) const; + AttributeList attribute(const String &name) const; - /*! + /*! * Sets the \a key attribute to the value of \a attribute. If an attribute * with the \a key is already present, it will be replaced. */ - void setAttribute(const String &name, const Attribute &attribute); + void setAttribute(const String &name, const Attribute &attribute); - /*! + /*! * Sets multiple \a values to the key \a name. */ - void setAttribute(const String &name, const AttributeList &values); + void setAttribute(const String &name, const AttributeList &values); - /*! + /*! * Sets the \a key attribute to the value of \a attribute. If an attribute * with the \a key is already present, it will be added to the list. */ - void addAttribute(const String &name, const Attribute &attribute); + void addAttribute(const String &name, const Attribute &attribute); - PropertyMap properties() const; - void removeUnsupportedProperties(const StringList& properties); - PropertyMap setProperties(const PropertyMap &properties); + PropertyMap properties() const; + void removeUnsupportedProperties(const StringList &properties); + PropertyMap setProperties(const PropertyMap &properties); - private: - - class TagPrivate; - TagPrivate *d; - }; - } -} -} + private: + class TagPrivate; + TagPrivate *d; +}; +} // namespace ASF +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/asf/asfutils.h b/3rdparty/taglib/asf/asfutils.h index 7cc409b66..15cfab1d6 100644 --- a/3rdparty/taglib/asf/asfutils.h +++ b/3rdparty/taglib/asf/asfutils.h @@ -31,76 +31,68 @@ #ifndef DO_NOT_DOCUMENT // tell Doxygen not to document this header namespace Strawberry_TagLib { -namespace TagLib -{ - namespace ASF - { - namespace - { +namespace TagLib { +namespace ASF { +namespace { - inline unsigned short readWORD(File *file, bool *ok = 0) - { - const ByteVector v = file->readBlock(2); - if(v.size() != 2) { - if(ok) *ok = false; - return 0; - } - if(ok) *ok = true; - return v.toUShort(false); - } - - inline unsigned int readDWORD(File *file, bool *ok = 0) - { - const ByteVector v = file->readBlock(4); - if(v.size() != 4) { - if(ok) *ok = false; - return 0; - } - if(ok) *ok = true; - return v.toUInt(false); - } - - inline long long readQWORD(File *file, bool *ok = 0) - { - const ByteVector v = file->readBlock(8); - if(v.size() != 8) { - if(ok) *ok = false; - return 0; - } - if(ok) *ok = true; - return v.toLongLong(false); - } - - inline String readString(File *file, int length) - { - ByteVector data = file->readBlock(length); - unsigned int size = data.size(); - while (size >= 2) { - if(data[size - 1] != '\0' || data[size - 2] != '\0') { - break; - } - size -= 2; - } - if(size != data.size()) { - data.resize(size); - } - return String(data, String::UTF16LE); - } - - inline ByteVector renderString(const String &str, bool includeLength = false) - { - ByteVector data = str.data(String::UTF16LE) + ByteVector::fromShort(0, false); - if(includeLength) { - data = ByteVector::fromShort(data.size(), false) + data; - } - return data; - } - - } +inline unsigned short readWORD(File *file, bool *ok = 0) { + const ByteVector v = file->readBlock(2); + if (v.size() != 2) { + if (ok) *ok = false; + return 0; } + if (ok) *ok = true; + return v.toUShort(false); } + +inline unsigned int readDWORD(File *file, bool *ok = 0) { + const ByteVector v = file->readBlock(4); + if (v.size() != 4) { + if (ok) *ok = false; + return 0; + } + if (ok) *ok = true; + return v.toUInt(false); } +inline long long readQWORD(File *file, bool *ok = 0) { + const ByteVector v = file->readBlock(8); + if (v.size() != 8) { + if (ok) *ok = false; + return 0; + } + if (ok) *ok = true; + return v.toLongLong(false); +} + +inline String readString(File *file, int length) { + ByteVector data = file->readBlock(length); + unsigned int size = data.size(); + while (size >= 2) { + if (data[size - 1] != '\0' || data[size - 2] != '\0') { + break; + } + size -= 2; + } + if (size != data.size()) { + data.resize(size); + } + return String(data, String::UTF16LE); +} + +inline ByteVector renderString(const String &str, bool includeLength = false) { + ByteVector data = str.data(String::UTF16LE) + ByteVector::fromShort(0, false); + if (includeLength) { + data = ByteVector::fromShort(data.size(), false) + data; + } + return data; +} + +} // namespace +} // namespace ASF +} // namespace TagLib +} // namespace Strawberry_TagLib + #endif #endif diff --git a/3rdparty/taglib/audioproperties.cpp b/3rdparty/taglib/audioproperties.cpp index d21896674..87deebf29 100644 --- a/3rdparty/taglib/audioproperties.cpp +++ b/3rdparty/taglib/audioproperties.cpp @@ -48,61 +48,55 @@ using namespace Strawberry_TagLib::TagLib; // This macro is a workaround for the fact that we can't add virtual functions. // Should be true virtual functions in taglib2. -#define VIRTUAL_FUNCTION_WORKAROUND(function_name, default_value) \ - if(dynamic_cast(this)) \ - return dynamic_cast(this)->function_name(); \ - else if(dynamic_cast(this)) \ - return dynamic_cast(this)->function_name(); \ - else if(dynamic_cast(this)) \ - return dynamic_cast(this)->function_name(); \ - else if(dynamic_cast(this)) \ - return dynamic_cast(this)->function_name(); \ - else if(dynamic_cast(this)) \ - return dynamic_cast(this)->function_name(); \ - else if(dynamic_cast(this)) \ - return dynamic_cast(this)->function_name(); \ - else if(dynamic_cast(this)) \ - return dynamic_cast(this)->function_name(); \ - else if(dynamic_cast(this)) \ - return dynamic_cast(this)->function_name(); \ - else if(dynamic_cast(this)) \ - return dynamic_cast(this)->function_name(); \ - else if(dynamic_cast(this)) \ - return dynamic_cast(this)->function_name(); \ - else if(dynamic_cast(this)) \ - return dynamic_cast(this)->function_name(); \ - else if(dynamic_cast(this)) \ - return dynamic_cast(this)->function_name(); \ - else if(dynamic_cast(this)) \ - return dynamic_cast(this)->function_name(); \ - else if(dynamic_cast(this)) \ - return dynamic_cast(this)->function_name(); \ - else if(dynamic_cast(this)) \ - return dynamic_cast(this)->function_name(); \ - else \ +#define VIRTUAL_FUNCTION_WORKAROUND(function_name, default_value) \ + if (dynamic_cast(this)) \ + return dynamic_cast(this)->function_name(); \ + else if (dynamic_cast(this)) \ + return dynamic_cast(this)->function_name(); \ + else if (dynamic_cast(this)) \ + return dynamic_cast(this)->function_name(); \ + else if (dynamic_cast(this)) \ + return dynamic_cast(this)->function_name(); \ + else if (dynamic_cast(this)) \ + return dynamic_cast(this)->function_name(); \ + else if (dynamic_cast(this)) \ + return dynamic_cast(this)->function_name(); \ + else if (dynamic_cast(this)) \ + return dynamic_cast(this)->function_name(); \ + else if (dynamic_cast(this)) \ + return dynamic_cast(this)->function_name(); \ + else if (dynamic_cast(this)) \ + return dynamic_cast(this)->function_name(); \ + else if (dynamic_cast(this)) \ + return dynamic_cast(this)->function_name(); \ + else if (dynamic_cast(this)) \ + return dynamic_cast(this)->function_name(); \ + else if (dynamic_cast(this)) \ + return dynamic_cast(this)->function_name(); \ + else if (dynamic_cast(this)) \ + return dynamic_cast(this)->function_name(); \ + else if (dynamic_cast(this)) \ + return dynamic_cast(this)->function_name(); \ + else if (dynamic_cast(this)) \ + return dynamic_cast(this)->function_name(); \ + else \ return (default_value); -class AudioProperties::AudioPropertiesPrivate -{ - +class AudioProperties::AudioPropertiesPrivate { }; //////////////////////////////////////////////////////////////////////////////// // public methods //////////////////////////////////////////////////////////////////////////////// -AudioProperties::~AudioProperties() -{ - +AudioProperties::~AudioProperties() { } -int AudioProperties::lengthInSeconds() const -{ +int AudioProperties::lengthInSeconds() const { VIRTUAL_FUNCTION_WORKAROUND(lengthInSeconds, 0) } -int AudioProperties::lengthInMilliseconds() const -{ +int AudioProperties::lengthInMilliseconds() const { VIRTUAL_FUNCTION_WORKAROUND(lengthInMilliseconds, 0) } @@ -110,8 +104,5 @@ int AudioProperties::lengthInMilliseconds() const // protected methods //////////////////////////////////////////////////////////////////////////////// -AudioProperties::AudioProperties(ReadStyle) : - d(0) -{ - +AudioProperties::AudioProperties(ReadStyle) : d(0) { } diff --git a/3rdparty/taglib/audioproperties.h b/3rdparty/taglib/audioproperties.h index 97fac396a..cacb62230 100644 --- a/3rdparty/taglib/audioproperties.h +++ b/3rdparty/taglib/audioproperties.h @@ -31,99 +31,96 @@ namespace Strawberry_TagLib { namespace TagLib { - //! A simple, abstract interface to common audio properties +//! A simple, abstract interface to common audio properties - /*! +/*! * The values here are common to most audio formats. For more specific, codec * dependent values, please see see the subclasses APIs. This is meant to * compliment the TagLib::File and TagLib::Tag APIs in providing a simple * interface that is sufficient for most applications. */ - class TAGLIB_EXPORT AudioProperties - { - public: - - /*! +class TAGLIB_EXPORT AudioProperties { + public: + /*! * Reading audio properties from a file can sometimes be very time consuming * and for the most accurate results can often involve reading the entire * file. Because in many situations speed is critical or the accuracy of the * values is not particularly important this allows the level of desired * accuracy to be set. */ - enum ReadStyle { - //! Read as little of the file as possible - Fast, - //! Read more of the file and make better values guesses - Average, - //! Read as much of the file as needed to report accurate values - Accurate - }; + enum ReadStyle { + //! Read as little of the file as possible + Fast, + //! Read more of the file and make better values guesses + Average, + //! Read as much of the file as needed to report accurate values + Accurate + }; - /*! + /*! * Destroys this AudioProperties instance. */ - virtual ~AudioProperties(); + virtual ~AudioProperties(); - /*! + /*! * Returns the length of the file in seconds. */ - virtual int length() const = 0; + virtual int length() const = 0; - /*! + /*! * Returns the length of the file in seconds. The length is rounded down to * the nearest whole second. * * \see lengthInMilliseconds() */ - // BIC: make virtual - int lengthInSeconds() const; + // BIC: make virtual + int lengthInSeconds() const; - /*! + /*! * Returns the length of the file in milliseconds. * * \see lengthInSeconds() */ - // BIC: make virtual - int lengthInMilliseconds() const; + // BIC: make virtual + int lengthInMilliseconds() const; - /*! + /*! * Returns the most appropriate bit rate for the file in kb/s. For constant * bitrate formats this is simply the bitrate of the file. For variable * bitrate formats this is either the average or nominal bitrate. */ - virtual int bitrate() const = 0; + virtual int bitrate() const = 0; - /*! + /*! * Returns the sample rate in Hz. */ - virtual int sampleRate() const = 0; + virtual int sampleRate() const = 0; - /*! + /*! * Returns the number of audio channels. */ - virtual int channels() const = 0; + virtual int channels() const = 0; - protected: - - /*! + protected: + /*! * Construct an audio properties instance. This is protected as this class * should not be instantiated directly, but should be instantiated via its * subclasses and can be fetched from the FileRef or File APIs. * * \see ReadStyle */ - AudioProperties(ReadStyle style); + AudioProperties(ReadStyle style); - private: - AudioProperties(const AudioProperties &); - AudioProperties &operator=(const AudioProperties &); + private: + AudioProperties(const AudioProperties &); + AudioProperties &operator=(const AudioProperties &); - class AudioPropertiesPrivate; - AudioPropertiesPrivate *d; - }; + class AudioPropertiesPrivate; + AudioPropertiesPrivate *d; +}; -} -} +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/dsdiff/dsdiffdiintag.cpp b/3rdparty/taglib/dsdiff/dsdiffdiintag.cpp index 027c850f4..aed84c1c4 100644 --- a/3rdparty/taglib/dsdiff/dsdiffdiintag.cpp +++ b/3rdparty/taglib/dsdiff/dsdiffdiintag.cpp @@ -30,128 +30,110 @@ using namespace Strawberry_TagLib::TagLib; using namespace DSDIFF::DIIN; -class DSDIFF::DIIN::Tag::TagPrivate -{ -public: - TagPrivate() - { +class DSDIFF::DIIN::Tag::TagPrivate { + public: + TagPrivate() { } String title; String artist; }; -DSDIFF::DIIN::Tag::Tag() : Strawberry_TagLib::TagLib::Tag() -{ +DSDIFF::DIIN::Tag::Tag() : Strawberry_TagLib::TagLib::Tag() { d = new TagPrivate; } -DSDIFF::DIIN::Tag::~Tag() -{ +DSDIFF::DIIN::Tag::~Tag() { delete d; } -String DSDIFF::DIIN::Tag::title() const -{ +String DSDIFF::DIIN::Tag::title() const { return d->title; } -String DSDIFF::DIIN::Tag::artist() const -{ +String DSDIFF::DIIN::Tag::artist() const { return d->artist; } -String DSDIFF::DIIN::Tag::album() const -{ +String DSDIFF::DIIN::Tag::album() const { return String(); } -String DSDIFF::DIIN::Tag::comment() const -{ +String DSDIFF::DIIN::Tag::comment() const { return String(); } -String DSDIFF::DIIN::Tag::genre() const -{ +String DSDIFF::DIIN::Tag::genre() const { return String(); } -unsigned int DSDIFF::DIIN::Tag::year() const -{ +unsigned int DSDIFF::DIIN::Tag::year() const { return 0; } -unsigned int DSDIFF::DIIN::Tag::track() const -{ +unsigned int DSDIFF::DIIN::Tag::track() const { return 0; } -void DSDIFF::DIIN::Tag::setTitle(const String &title) -{ - if(title.isNull() || title.isEmpty()) +void DSDIFF::DIIN::Tag::setTitle(const String &title) { + if (title.isNull() || title.isEmpty()) d->title = String(); else d->title = title; } -void DSDIFF::DIIN::Tag::setArtist(const String &artist) -{ - if(artist.isNull() || artist.isEmpty()) +void DSDIFF::DIIN::Tag::setArtist(const String &artist) { + if (artist.isNull() || artist.isEmpty()) d->artist = String(); else d->artist = artist; } -void DSDIFF::DIIN::Tag::setAlbum(const String &) -{ +void DSDIFF::DIIN::Tag::setAlbum(const String &) { } -void DSDIFF::DIIN::Tag::setComment(const String &) -{ +void DSDIFF::DIIN::Tag::setComment(const String &) { } -void DSDIFF::DIIN::Tag::setGenre(const String &) -{ +void DSDIFF::DIIN::Tag::setGenre(const String &) { } -void DSDIFF::DIIN::Tag::setYear(unsigned int) -{ +void DSDIFF::DIIN::Tag::setYear(unsigned int) { } -void DSDIFF::DIIN::Tag::setTrack(unsigned int) -{ +void DSDIFF::DIIN::Tag::setTrack(unsigned int) { } -PropertyMap DSDIFF::DIIN::Tag::properties() const -{ +PropertyMap DSDIFF::DIIN::Tag::properties() const { PropertyMap properties; properties["TITLE"] = d->title; properties["ARTIST"] = d->artist; return properties; } -PropertyMap DSDIFF::DIIN::Tag::setProperties(const PropertyMap &origProps) -{ +PropertyMap DSDIFF::DIIN::Tag::setProperties(const PropertyMap &origProps) { PropertyMap properties(origProps); properties.removeEmpty(); StringList oneValueSet; - if(properties.contains("TITLE")) { + if (properties.contains("TITLE")) { d->title = properties["TITLE"].front(); oneValueSet.append("TITLE"); - } else + } + else d->title = String(); - if(properties.contains("ARTIST")) { + if (properties.contains("ARTIST")) { d->artist = properties["ARTIST"].front(); oneValueSet.append("ARTIST"); - } else + } + else d->artist = String(); // for each tag that has been set above, remove the first entry in the corresponding // value list. The others will be returned as unsupported by this format. - for(StringList::Iterator it = oneValueSet.begin(); it != oneValueSet.end(); ++it) { - if(properties[*it].size() == 1) + for (StringList::Iterator it = oneValueSet.begin(); it != oneValueSet.end(); ++it) { + if (properties[*it].size() == 1) properties.erase(*it); else properties[*it].erase(properties[*it].begin()); @@ -159,4 +141,3 @@ PropertyMap DSDIFF::DIIN::Tag::setProperties(const PropertyMap &origProps) return properties; } - diff --git a/3rdparty/taglib/dsdiff/dsdiffdiintag.h b/3rdparty/taglib/dsdiff/dsdiffdiintag.h index fb1506bbf..f129281a4 100644 --- a/3rdparty/taglib/dsdiff/dsdiffdiintag.h +++ b/3rdparty/taglib/dsdiff/dsdiffdiintag.h @@ -31,102 +31,101 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace DSDIFF { +namespace DSDIFF { - namespace DIIN { +namespace DIIN { - /*! +/*! * Tags from the Edited Master Chunk Info * * Only Title and Artist tags are supported */ - class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag - { - public: - Tag(); - virtual ~Tag(); +class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag { + public: + Tag(); + virtual ~Tag(); - /*! + /*! * Returns the track name; if no track name is present in the tag * String() will be returned. */ - String title() const; + String title() const; - /*! + /*! * Returns the artist name; if no artist name is present in the tag * String() will be returned. */ - String artist() const; + String artist() const; - /*! + /*! * Not supported. Therefore always returns String(). */ - String album() const; + String album() const; - /*! + /*! * Not supported. Therefore always returns String(). */ - String comment() const; + String comment() const; - /*! + /*! * Not supported. Therefore always returns String(). */ - String genre() const; + String genre() const; - /*! + /*! * Not supported. Therefore always returns 0. */ - unsigned int year() const; + unsigned int year() const; - /*! + /*! * Not supported. Therefore always returns 0. */ - unsigned int track() const; + unsigned int track() const; - /*! + /*! * Sets the title to \a title. If \a title is String() then this * value will be cleared. */ - void setTitle(const String &title); + void setTitle(const String &title); - /*! + /*! * Sets the artist to \a artist. If \a artist is String() then this * value will be cleared. */ - void setArtist(const String &artist); + void setArtist(const String &artist); - /*! + /*! * Not supported and therefore ignored. */ - void setAlbum(const String &album); + void setAlbum(const String &album); - /*! + /*! * Not supported and therefore ignored. */ - void setComment(const String &comment); + void setComment(const String &comment); - /*! + /*! * Not supported and therefore ignored. */ - void setGenre(const String &genre); + void setGenre(const String &genre); - /*! + /*! * Not supported and therefore ignored. */ - void setYear(unsigned int year); + void setYear(unsigned int year); - /*! + /*! * Not supported and therefore ignored. */ - void setTrack(unsigned int track); + void setTrack(unsigned int track); - /*! + /*! * Implements the unified property interface -- export function. * Since the DIIN tag is very limited, the exported map is as well. */ - PropertyMap properties() const; + PropertyMap properties() const; - /*! + /*! * Implements the unified property interface -- import function. * Because of the limitations of the DIIN file tag, any tags besides * TITLE and ARTIST, will be @@ -134,19 +133,18 @@ namespace TagLib { * all but the first will be contained in the returned map of unsupported * properties. */ - PropertyMap setProperties(const PropertyMap &); + PropertyMap setProperties(const PropertyMap &); - private: - Tag(const Tag &); - Tag &operator=(const Tag &); + private: + Tag(const Tag &); + Tag &operator=(const Tag &); - class TagPrivate; - TagPrivate *d; - }; - } - } -} -} + class TagPrivate; + TagPrivate *d; +}; +} // namespace DIIN +} // namespace DSDIFF +} // namespace TagLib +} // namespace Strawberry_TagLib #endif - diff --git a/3rdparty/taglib/dsdiff/dsdifffile.cpp b/3rdparty/taglib/dsdiff/dsdifffile.cpp index b83c99e0c..1bbc2e846 100644 --- a/3rdparty/taglib/dsdiff/dsdifffile.cpp +++ b/3rdparty/taglib/dsdiff/dsdifffile.cpp @@ -37,70 +37,62 @@ using namespace Strawberry_TagLib::TagLib; -namespace -{ - struct Chunk64 - { - ByteVector name; - unsigned long long offset; - unsigned long long size; - char padding; - }; +namespace { +struct Chunk64 { + ByteVector name; + unsigned long long offset; + unsigned long long size; + char padding; +}; - typedef std::vector ChunkList; +typedef std::vector ChunkList; - int chunkIndex(const ChunkList &chunks, const ByteVector &id) - { - for (unsigned long int i = 0 ; i < chunks.size() ; i++) { - if(chunks[i].name == id) - return i; - } - - return -1; +int chunkIndex(const ChunkList &chunks, const ByteVector &id) { + for (unsigned long int i = 0; i < chunks.size(); i++) { + if (chunks[i].name == id) + return i; } - bool isValidChunkID(const ByteVector &name) - { - if(name.size() != 4) - return false; - - for (int i = 0 ; i < 4 ; i++) { - if (name[i] < 32) - return false; - } - - return true; - } - - enum { - ID3v2Index = 0, - DIINIndex = 1 - }; - enum { - PROPChunk = 0, - DIINChunk = 1 - }; + return -1; } -class DSDIFF::File::FilePrivate -{ -public: - FilePrivate() : - endianness(BigEndian), - size(0), - isID3InPropChunk(false), - duplicateID3V2chunkIndex(-1), - properties(0), - id3v2TagChunkID("ID3 "), - hasID3v2(false), - hasDiin(false) - { +bool isValidChunkID(const ByteVector &name) { + if (name.size() != 4) + return false; + + for (int i = 0; i < 4; i++) { + if (name[i] < 32) + return false; + } + + return true; +} + +enum { + ID3v2Index = 0, + DIINIndex = 1 +}; +enum { + PROPChunk = 0, + DIINChunk = 1 +}; +} // namespace + +class DSDIFF::File::FilePrivate { + public: + FilePrivate() : endianness(BigEndian), + size(0), + isID3InPropChunk(false), + duplicateID3V2chunkIndex(-1), + properties(0), + id3v2TagChunkID("ID3 "), + hasID3v2(false), + hasDiin(false) { childChunkIndex[ID3v2Index] = -1; childChunkIndex[DIINIndex] = -1; } - ~FilePrivate() - { + ~FilePrivate() { delete properties; } @@ -135,12 +127,11 @@ public: // static members //////////////////////////////////////////////////////////////////////////////// -bool DSDIFF::File::isSupported(IOStream *stream) -{ - // A DSDIFF file has to start with "FRM8????????DSD ". +bool DSDIFF::File::isSupported(IOStream *stream) { + // A DSDIFF file has to start with "FRM8????????DSD ". - const ByteVector id = Utils::readHeader(stream, 16, false); - return (id.startsWith("FRM8") && id.containsAt("DSD ", 12)); + const ByteVector id = Utils::readHeader(stream, 16, false); + return (id.startsWith("FRM8") && id.containsAt("DSD ", 12)); } //////////////////////////////////////////////////////////////////////////////// @@ -148,107 +139,93 @@ bool DSDIFF::File::isSupported(IOStream *stream) //////////////////////////////////////////////////////////////////////////////// DSDIFF::File::File(FileName file, bool readProperties, - Properties::ReadStyle propertiesStyle) : Strawberry_TagLib::TagLib::File(file) -{ + Properties::ReadStyle propertiesStyle) : Strawberry_TagLib::TagLib::File(file) { d = new FilePrivate; d->endianness = BigEndian; - if(isOpen()) + if (isOpen()) read(readProperties, propertiesStyle); } DSDIFF::File::File(IOStream *stream, bool readProperties, - Properties::ReadStyle propertiesStyle) : Strawberry_TagLib::TagLib::File(stream) -{ + Properties::ReadStyle propertiesStyle) : Strawberry_TagLib::TagLib::File(stream) { d = new FilePrivate; d->endianness = BigEndian; - if(isOpen()) + if (isOpen()) read(readProperties, propertiesStyle); } -DSDIFF::File::~File() -{ +DSDIFF::File::~File() { delete d; } -Strawberry_TagLib::TagLib::Tag *DSDIFF::File::tag() const -{ +Strawberry_TagLib::TagLib::Tag *DSDIFF::File::tag() const { return &d->tag; } -ID3v2::Tag *DSDIFF::File::ID3v2Tag(bool create) const -{ +ID3v2::Tag *DSDIFF::File::ID3v2Tag(bool create) const { return d->tag.access(ID3v2Index, create); } -bool DSDIFF::File::hasID3v2Tag() const -{ +bool DSDIFF::File::hasID3v2Tag() const { return d->hasID3v2; } -DSDIFF::DIIN::Tag *DSDIFF::File::DIINTag(bool create) const -{ +DSDIFF::DIIN::Tag *DSDIFF::File::DIINTag(bool create) const { return d->tag.access(DIINIndex, create); } -bool DSDIFF::File::hasDIINTag() const -{ +bool DSDIFF::File::hasDIINTag() const { return d->hasDiin; } -PropertyMap DSDIFF::File::properties() const -{ - if(d->hasID3v2) +PropertyMap DSDIFF::File::properties() const { + if (d->hasID3v2) return d->tag.access(ID3v2Index, false)->properties(); return PropertyMap(); } -void DSDIFF::File::removeUnsupportedProperties(const StringList &unsupported) -{ - if(d->hasID3v2) +void DSDIFF::File::removeUnsupportedProperties(const StringList &unsupported) { + if (d->hasID3v2) d->tag.access(ID3v2Index, false)->removeUnsupportedProperties(unsupported); - if(d->hasDiin) + if (d->hasDiin) d->tag.access(DIINIndex, false)->removeUnsupportedProperties(unsupported); } -PropertyMap DSDIFF::File::setProperties(const PropertyMap &properties) -{ +PropertyMap DSDIFF::File::setProperties(const PropertyMap &properties) { return d->tag.access(ID3v2Index, true)->setProperties(properties); } -DSDIFF::Properties *DSDIFF::File::audioProperties() const -{ +DSDIFF::Properties *DSDIFF::File::audioProperties() const { return d->properties; } -bool DSDIFF::File::save() -{ +bool DSDIFF::File::save() { return save(AllTags); } -bool DSDIFF::File::save(TagTypes tags, StripTags, ID3v2::Version version) -{ - if(readOnly()) { +bool DSDIFF::File::save(TagTypes tags, StripTags, ID3v2::Version version) { + if (readOnly()) { debug("DSDIFF::File::save() -- File is read only."); return false; } - if(!isValid()) { + if (!isValid()) { debug("DSDIFF::File::save() -- Trying to save invalid file."); return false; } //if(strip == StripOthers || strip == StripAll) - //File::strip(static_cast(AllTags & ~tags)); + //File::strip(static_cast(AllTags & ~tags)); // First: save ID3V2 chunk ID3v2::Tag *id3v2Tag = d->tag.access(ID3v2Index, false); - if(tags & ID3v2 && id3v2Tag) { - if(d->isID3InPropChunk) { - if(id3v2Tag && !id3v2Tag->isEmpty()) { + if (tags & ID3v2 && id3v2Tag) { + if (d->isID3InPropChunk) { + if (id3v2Tag && !id3v2Tag->isEmpty()) { setChildChunkData(d->id3v2TagChunkID, id3v2Tag->render(version), PROPChunk); d->hasID3v2 = true; } @@ -259,7 +236,7 @@ bool DSDIFF::File::save(TagTypes tags, StripTags, ID3v2::Version version) } } else { - if(id3v2Tag && !id3v2Tag->isEmpty()) { + if (id3v2Tag && !id3v2Tag->isEmpty()) { setRootChunkData(d->id3v2TagChunkID, id3v2Tag->render(version)); d->hasID3v2 = true; } @@ -275,8 +252,8 @@ bool DSDIFF::File::save(TagTypes tags, StripTags, ID3v2::Version version) DSDIFF::DIIN::Tag *diinTag = d->tag.access(DIINIndex, false); - if(tags & DIIN && diinTag) { - if(!diinTag->title().isEmpty()) { + if (tags & DIIN && diinTag) { + if (!diinTag->title().isEmpty()) { ByteVector diinTitle; diinTitle.append(ByteVector::fromUInt(diinTag->title().size(), d->endianness == BigEndian)); diinTitle.append(ByteVector::fromCString(diinTag->title().toCString())); @@ -285,7 +262,7 @@ bool DSDIFF::File::save(TagTypes tags, StripTags, ID3v2::Version version) else setChildChunkData("DITI", ByteVector(), DIINChunk); - if(!diinTag->artist().isEmpty()) { + if (!diinTag->artist().isEmpty()) { ByteVector diinArtist; diinArtist.append(ByteVector::fromUInt(diinTag->artist().size(), d->endianness == BigEndian)); diinArtist.append(ByteVector::fromCString(diinTag->artist().toCString())); @@ -296,7 +273,7 @@ bool DSDIFF::File::save(TagTypes tags, StripTags, ID3v2::Version version) } // Third: remove the duplicate ID3V2 chunk (inside PROP chunk) if any - if(d->duplicateID3V2chunkIndex>=0) { + if (d->duplicateID3V2chunkIndex >= 0) { setChildChunkData(d->duplicateID3V2chunkIndex, ByteVector(), PROPChunk); d->duplicateID3V2chunkIndex = -1; } @@ -304,9 +281,8 @@ bool DSDIFF::File::save(TagTypes tags, StripTags, ID3v2::Version version) return true; } -void DSDIFF::File::strip(TagTypes tags) -{ - if(tags & ID3v2) { +void DSDIFF::File::strip(TagTypes tags) { + if (tags & ID3v2) { removeRootChunk("ID3 "); removeRootChunk("id3 "); d->hasID3v2 = false; @@ -314,7 +290,7 @@ void DSDIFF::File::strip(TagTypes tags) /// TODO: needs to also account for ID3v2 tags under the PROP chunk } - if(tags & DIIN) { + if (tags & DIIN) { removeRootChunk("DITI"); removeRootChunk("DIAR"); d->hasDiin = false; @@ -326,35 +302,31 @@ void DSDIFF::File::strip(TagTypes tags) // private members //////////////////////////////////////////////////////////////////////////////// -void DSDIFF::File::removeRootChunk(unsigned int i) -{ - unsigned long long chunkSize = d->chunks[i].size + d->chunks[i].padding + 12; +void DSDIFF::File::removeRootChunk(unsigned int i) { + unsigned long long chunkSize = d->chunks[i].size + d->chunks[i].padding + 12; - d->size -= chunkSize; - insert(ByteVector::fromLongLong(d->size, d->endianness == BigEndian), 4, 8); + d->size -= chunkSize; + insert(ByteVector::fromLongLong(d->size, d->endianness == BigEndian), 4, 8); - removeBlock(d->chunks[i].offset - 12, chunkSize); + removeBlock(d->chunks[i].offset - 12, chunkSize); - // Update the internal offsets + // Update the internal offsets - for(unsigned long r = i + 1; r < d->chunks.size(); r++) - d->chunks[r].offset = d->chunks[r - 1].offset + 12 - + d->chunks[r - 1].size + d->chunks[r - 1].padding; + for (unsigned long r = i + 1; r < d->chunks.size(); r++) + d->chunks[r].offset = d->chunks[r - 1].offset + 12 + d->chunks[r - 1].size + d->chunks[r - 1].padding; - d->chunks.erase(d->chunks.begin() + i); + d->chunks.erase(d->chunks.begin() + i); } -void DSDIFF::File::removeRootChunk(const ByteVector &id) -{ +void DSDIFF::File::removeRootChunk(const ByteVector &id) { int i = chunkIndex(d->chunks, id); - if(i >= 0) + if (i >= 0) removeRootChunk(i); } -void DSDIFF::File::setRootChunkData(unsigned int i, const ByteVector &data) -{ - if(data.isEmpty()) { +void DSDIFF::File::setRootChunkData(unsigned int i, const ByteVector &data) { + if (data.isEmpty()) { removeRootChunk(i); return; } @@ -368,9 +340,9 @@ void DSDIFF::File::setRootChunkData(unsigned int i, const ByteVector &data) // Now update the specific chunk writeChunk(d->chunks[i].name, - data, - d->chunks[i].offset - 12, - d->chunks[i].size + d->chunks[i].padding + 12); + data, + d->chunks[i].offset - 12, + d->chunks[i].size + d->chunks[i].padding + 12); d->chunks[i].size = data.size(); d->chunks[i].padding = (data.size() & 0x01) ? 1 : 0; @@ -380,16 +352,15 @@ void DSDIFF::File::setRootChunkData(unsigned int i, const ByteVector &data) updateRootChunksStructure(i + 1); } -void DSDIFF::File::setRootChunkData(const ByteVector &name, const ByteVector &data) -{ - if(d->chunks.size() == 0) { +void DSDIFF::File::setRootChunkData(const ByteVector &name, const ByteVector &data) { + if (d->chunks.size() == 0) { debug("DSDIFF::File::setPropChunkData - No valid chunks found."); return; } int i = chunkIndex(d->chunks, name); - if(i >= 0) { + if (i >= 0) { setRootChunkData(i, data); return; } @@ -404,10 +375,10 @@ void DSDIFF::File::setRootChunkData(const ByteVector &name, const ByteVector &da // Now add the chunk to the file writeChunk(name, - data, - offset, - std::max(0, length() - offset), - (offset & 1) ? 1 : 0); + data, + offset, + std::max(0, length() - offset), + (offset & 1) ? 1 : 0); Chunk64 chunk; chunk.name = name; @@ -418,53 +389,49 @@ void DSDIFF::File::setRootChunkData(const ByteVector &name, const ByteVector &da d->chunks.push_back(chunk); } -void DSDIFF::File::removeChildChunk(unsigned int i, unsigned int childChunkNum) -{ - ChunkList &childChunks = d->childChunks[childChunkNum]; +void DSDIFF::File::removeChildChunk(unsigned int i, unsigned int childChunkNum) { + ChunkList &childChunks = d->childChunks[childChunkNum]; - // Update global size + // Update global size - unsigned long long removedChunkTotalSize = childChunks[i].size + childChunks[i].padding + 12; - d->size -= removedChunkTotalSize; - insert(ByteVector::fromLongLong(d->size, d->endianness == BigEndian), 4, 8); + unsigned long long removedChunkTotalSize = childChunks[i].size + childChunks[i].padding + 12; + d->size -= removedChunkTotalSize; + insert(ByteVector::fromLongLong(d->size, d->endianness == BigEndian), 4, 8); - // Update child chunk size + // Update child chunk size - d->chunks[d->childChunkIndex[childChunkNum]].size -= removedChunkTotalSize; - insert(ByteVector::fromLongLong(d->chunks[d->childChunkIndex[childChunkNum]].size, - d->endianness == BigEndian), - d->chunks[d->childChunkIndex[childChunkNum]].offset - 8, 8); - // Remove the chunk + d->chunks[d->childChunkIndex[childChunkNum]].size -= removedChunkTotalSize; + insert(ByteVector::fromLongLong(d->chunks[d->childChunkIndex[childChunkNum]].size, + d->endianness == BigEndian), + d->chunks[d->childChunkIndex[childChunkNum]].offset - 8, 8); + // Remove the chunk - removeBlock(childChunks[i].offset - 12, removedChunkTotalSize); + removeBlock(childChunks[i].offset - 12, removedChunkTotalSize); - // Update the internal offsets - // For child chunks + // Update the internal offsets + // For child chunks - if((i + 1) < childChunks.size()) { - childChunks[i + 1].offset = childChunks[i].offset; - i++; - for(i++; i < childChunks.size(); i++) - childChunks[i].offset = childChunks[i - 1].offset + 12 - + childChunks[i - 1].size + childChunks[i - 1].padding; - } + if ((i + 1) < childChunks.size()) { + childChunks[i + 1].offset = childChunks[i].offset; + i++; + for (i++; i < childChunks.size(); i++) + childChunks[i].offset = childChunks[i - 1].offset + 12 + childChunks[i - 1].size + childChunks[i - 1].padding; + } - // And for root chunks + // And for root chunks - for(i = d->childChunkIndex[childChunkNum] + 1; i < d->chunks.size(); i++) - d->chunks[i].offset = d->chunks[i - 1].offset + 12 - + d->chunks[i - 1].size + d->chunks[i - 1].padding; + for (i = d->childChunkIndex[childChunkNum] + 1; i < d->chunks.size(); i++) + d->chunks[i].offset = d->chunks[i - 1].offset + 12 + d->chunks[i - 1].size + d->chunks[i - 1].padding; - childChunks.erase(childChunks.begin() + i); + childChunks.erase(childChunks.begin() + i); } void DSDIFF::File::setChildChunkData(unsigned int i, - const ByteVector &data, - unsigned int childChunkNum) -{ + const ByteVector &data, + unsigned int childChunkNum) { ChunkList &childChunks = d->childChunks[childChunkNum]; - if(data.isEmpty()) { + if (data.isEmpty()) { removeChildChunk(i, childChunkNum); return; } @@ -481,42 +448,40 @@ void DSDIFF::File::setChildChunkData(unsigned int i, d->chunks[d->childChunkIndex[childChunkNum]].size += ((data.size() + 1) & ~1) - (childChunks[i].size + childChunks[i].padding); insert(ByteVector::fromLongLong(d->chunks[d->childChunkIndex[childChunkNum]].size, - d->endianness == BigEndian), - d->chunks[d->childChunkIndex[childChunkNum]].offset - 8, 8); + d->endianness == BigEndian), + d->chunks[d->childChunkIndex[childChunkNum]].offset - 8, 8); // Now update the specific chunk writeChunk(childChunks[i].name, - data, - childChunks[i].offset - 12, - childChunks[i].size + childChunks[i].padding + 12); + data, + childChunks[i].offset - 12, + childChunks[i].size + childChunks[i].padding + 12); childChunks[i].size = data.size(); childChunks[i].padding = (data.size() & 0x01) ? 1 : 0; // Now update the internal offsets // For child Chunks - for(i++; i < childChunks.size(); i++) - childChunks[i].offset = childChunks[i - 1].offset + 12 - + childChunks[i - 1].size + childChunks[i - 1].padding; + for (i++; i < childChunks.size(); i++) + childChunks[i].offset = childChunks[i - 1].offset + 12 + childChunks[i - 1].size + childChunks[i - 1].padding; // And for root chunks updateRootChunksStructure(d->childChunkIndex[childChunkNum] + 1); } void DSDIFF::File::setChildChunkData(const ByteVector &name, - const ByteVector &data, - unsigned int childChunkNum) -{ + const ByteVector &data, + unsigned int childChunkNum) { ChunkList &childChunks = d->childChunks[childChunkNum]; - if(childChunks.size() == 0) { + if (childChunks.size() == 0) { debug("DSDIFF::File::setPropChunkData - No valid chunks found."); return; } - for(unsigned int i = 0; i < childChunks.size(); i++) { - if(childChunks[i].name == name) { + for (unsigned int i = 0; i < childChunks.size(); i++) { + if (childChunks[i].name == name) { setChildChunkData(i, data, childChunkNum); return; } @@ -524,7 +489,7 @@ void DSDIFF::File::setChildChunkData(const ByteVector &name, // Do not attempt to remove a non existing chunk - if(data.isEmpty()) + if (data.isEmpty()) return; // Couldn't find an existing chunk, so let's create a new one. @@ -539,21 +504,20 @@ void DSDIFF::File::setChildChunkData(const ByteVector &name, // And the child chunk size - d->chunks[d->childChunkIndex[childChunkNum]].size += (offset & 1) - + ((data.size() + 1) & ~1) + 12; + d->chunks[d->childChunkIndex[childChunkNum]].size += (offset & 1) + ((data.size() + 1) & ~1) + 12; insert(ByteVector::fromLongLong(d->chunks[d->childChunkIndex[childChunkNum]].size, - d->endianness == BigEndian), - d->chunks[d->childChunkIndex[childChunkNum]].offset - 8, 8); + d->endianness == BigEndian), + d->chunks[d->childChunkIndex[childChunkNum]].offset - 8, 8); // Now add the chunk to the file unsigned long long nextRootChunkIdx = length(); - if((d->childChunkIndex[childChunkNum] + 1) < static_cast(d->chunks.size())) + if ((d->childChunkIndex[childChunkNum] + 1) < static_cast(d->chunks.size())) nextRootChunkIdx = d->chunks[d->childChunkIndex[childChunkNum] + 1].offset - 12; writeChunk(name, data, offset, - std::max(0, nextRootChunkIdx - offset), - (offset & 1) ? 1 : 0); + std::max(0, nextRootChunkIdx - offset), + (offset & 1) ? 1 : 0); // For root chunks @@ -568,37 +532,31 @@ void DSDIFF::File::setChildChunkData(const ByteVector &name, childChunks.push_back(chunk); } -void DSDIFF::File::updateRootChunksStructure(unsigned int startingChunk) -{ - for(unsigned int i = startingChunk; i < d->chunks.size(); i++) - d->chunks[i].offset = d->chunks[i - 1].offset + 12 - + d->chunks[i - 1].size + d->chunks[i - 1].padding; +void DSDIFF::File::updateRootChunksStructure(unsigned int startingChunk) { + for (unsigned int i = startingChunk; i < d->chunks.size(); i++) + d->chunks[i].offset = d->chunks[i - 1].offset + 12 + d->chunks[i - 1].size + d->chunks[i - 1].padding; // Update childchunks structure as well - if(d->childChunkIndex[PROPChunk] >= static_cast(startingChunk)) { + if (d->childChunkIndex[PROPChunk] >= static_cast(startingChunk)) { ChunkList &childChunksToUpdate = d->childChunks[PROPChunk]; - if(childChunksToUpdate.size() > 0) { + if (childChunksToUpdate.size() > 0) { childChunksToUpdate[0].offset = d->chunks[d->childChunkIndex[PROPChunk]].offset + 12; - for(unsigned int i = 1; i < childChunksToUpdate.size(); i++) - childChunksToUpdate[i].offset = childChunksToUpdate[i - 1].offset + 12 - + childChunksToUpdate[i - 1].size + childChunksToUpdate[i - 1].padding; + for (unsigned int i = 1; i < childChunksToUpdate.size(); i++) + childChunksToUpdate[i].offset = childChunksToUpdate[i - 1].offset + 12 + childChunksToUpdate[i - 1].size + childChunksToUpdate[i - 1].padding; } - } - if(d->childChunkIndex[DIINChunk] >= static_cast(startingChunk)) { + if (d->childChunkIndex[DIINChunk] >= static_cast(startingChunk)) { ChunkList &childChunksToUpdate = d->childChunks[DIINChunk]; - if(childChunksToUpdate.size() > 0) { + if (childChunksToUpdate.size() > 0) { childChunksToUpdate[0].offset = d->chunks[d->childChunkIndex[DIINChunk]].offset + 12; - for(unsigned int i = 1; i < childChunksToUpdate.size(); i++) - childChunksToUpdate[i].offset = childChunksToUpdate[i - 1].offset + 12 - + childChunksToUpdate[i - 1].size + childChunksToUpdate[i - 1].padding; + for (unsigned int i = 1; i < childChunksToUpdate.size(); i++) + childChunksToUpdate[i].offset = childChunksToUpdate[i - 1].offset + 12 + childChunksToUpdate[i - 1].size + childChunksToUpdate[i - 1].padding; } } } -void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesStyle) -{ +void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesStyle) { bool bigEndian = (d->endianness == BigEndian); d->type = readBlock(4); @@ -607,20 +565,19 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty // + 12: chunk header at least, fix for additional junk bytes - while(tell() + 12 <= length()) { + while (tell() + 12 <= length()) { ByteVector chunkName = readBlock(4); unsigned long long chunkSize = readBlock(8).toLongLong(bigEndian); - if(!isValidChunkID(chunkName)) { + if (!isValidChunkID(chunkName)) { debug("DSDIFF::File::read() -- Chunk '" + chunkName + "' has invalid ID"); setValid(false); break; } - if(static_cast(tell()) + chunkSize > - static_cast(length())) { - debug("DSDIFF::File::read() -- Chunk '" + chunkName - + "' has invalid size (larger than the file size)"); + if (static_cast(tell()) + chunkSize > + static_cast(length())) { + debug("DSDIFF::File::read() -- Chunk '" + chunkName + "' has invalid size (larger than the file size)"); setValid(false); break; } @@ -636,9 +593,9 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty chunk.padding = 0; long uPosNotPadded = tell(); - if((uPosNotPadded & 0x01) != 0) { + if ((uPosNotPadded & 0x01) != 0) { ByteVector iByte = readBlock(1); - if((iByte.size() != 1) || (iByte[0] != 0)) + if ((iByte.size() != 1) || (iByte[0] != 0)) // Not well formed, re-seek seek(uPosNotPadded, Beginning); else @@ -656,36 +613,35 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty // For DST compressed frames unsigned short dstFrameRate = 0; - for(unsigned int i = 0; i < d->chunks.size(); i++) { - if(d->chunks[i].name == "DSD ") { + for (unsigned int i = 0; i < d->chunks.size(); i++) { + if (d->chunks[i].name == "DSD ") { lengthDSDSamplesTimeChannels = d->chunks[i].size * 8; audioDataSizeinBytes = d->chunks[i].size; } - else if(d->chunks[i].name == "DST ") { + else if (d->chunks[i].name == "DST ") { // Now decode the chunks inside the DST chunk to read the DST Frame Information one long long dstChunkEnd = d->chunks[i].offset + d->chunks[i].size; seek(d->chunks[i].offset); audioDataSizeinBytes = d->chunks[i].size; - while(tell() + 12 <= dstChunkEnd) { + while (tell() + 12 <= dstChunkEnd) { ByteVector dstChunkName = readBlock(4); long long dstChunkSize = readBlock(8).toLongLong(bigEndian); - if(!isValidChunkID(dstChunkName)) { + if (!isValidChunkID(dstChunkName)) { debug("DSDIFF::File::read() -- DST Chunk '" + dstChunkName + "' has invalid ID"); setValid(false); break; } - if(static_cast(tell()) + dstChunkSize > dstChunkEnd) { - debug("DSDIFF::File::read() -- DST Chunk '" + dstChunkName - + "' has invalid size (larger than the DST chunk)"); + if (static_cast(tell()) + dstChunkSize > dstChunkEnd) { + debug("DSDIFF::File::read() -- DST Chunk '" + dstChunkName + "' has invalid size (larger than the DST chunk)"); setValid(false); break; } - if(dstChunkName == "FRTE") { + if (dstChunkName == "FRTE") { // Found the DST frame information chunk dstNumFrames = readBlock(4).toUInt(bigEndian); dstFrameRate = readBlock(2).toUShort(bigEndian); @@ -697,33 +653,32 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty // Check padding long uPosNotPadded = tell(); - if((uPosNotPadded & 0x01) != 0) { + if ((uPosNotPadded & 0x01) != 0) { ByteVector iByte = readBlock(1); - if((iByte.size() != 1) || (iByte[0] != 0)) + if ((iByte.size() != 1) || (iByte[0] != 0)) // Not well formed, re-seek seek(uPosNotPadded, Beginning); } } } - else if(d->chunks[i].name == "PROP") { + else if (d->chunks[i].name == "PROP") { d->childChunkIndex[PROPChunk] = i; // Now decodes the chunks inside the PROP chunk long long propChunkEnd = d->chunks[i].offset + d->chunks[i].size; // +4 to remove the 'SND ' marker at beginning of 'PROP' chunk seek(d->chunks[i].offset + 4); - while(tell() + 12 <= propChunkEnd) { + while (tell() + 12 <= propChunkEnd) { ByteVector propChunkName = readBlock(4); long long propChunkSize = readBlock(8).toLongLong(bigEndian); - if(!isValidChunkID(propChunkName)) { + if (!isValidChunkID(propChunkName)) { debug("DSDIFF::File::read() -- PROP Chunk '" + propChunkName + "' has invalid ID"); setValid(false); break; } - if(static_cast(tell()) + propChunkSize > propChunkEnd) { - debug("DSDIFF::File::read() -- PROP Chunk '" + propChunkName - + "' has invalid size (larger than the PROP chunk)"); + if (static_cast(tell()) + propChunkSize > propChunkEnd) { + debug("DSDIFF::File::read() -- PROP Chunk '" + propChunkName + "' has invalid size (larger than the PROP chunk)"); setValid(false); break; } @@ -738,9 +693,9 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty // Check padding chunk.padding = 0; long uPosNotPadded = tell(); - if((uPosNotPadded & 0x01) != 0) { + if ((uPosNotPadded & 0x01) != 0) { ByteVector iByte = readBlock(1); - if((iByte.size() != 1) || (iByte[0] != 0)) + if ((iByte.size() != 1) || (iByte[0] != 0)) // Not well formed, re-seek seek(uPosNotPadded, Beginning); else @@ -749,7 +704,7 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty d->childChunks[PROPChunk].push_back(chunk); } } - else if(d->chunks[i].name == "DIIN") { + else if (d->chunks[i].name == "DIIN") { d->childChunkIndex[DIINChunk] = i; d->hasDiin = true; @@ -758,19 +713,18 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty long long diinChunkEnd = d->chunks[i].offset + d->chunks[i].size; seek(d->chunks[i].offset); - while(tell() + 12 <= diinChunkEnd) { + while (tell() + 12 <= diinChunkEnd) { ByteVector diinChunkName = readBlock(4); long long diinChunkSize = readBlock(8).toLongLong(bigEndian); - if(!isValidChunkID(diinChunkName)) { + if (!isValidChunkID(diinChunkName)) { debug("DSDIFF::File::read() -- DIIN Chunk '" + diinChunkName + "' has invalid ID"); setValid(false); break; } - if(static_cast(tell()) + diinChunkSize > diinChunkEnd) { - debug("DSDIFF::File::read() -- DIIN Chunk '" + diinChunkName - + "' has invalid size (larger than the DIIN chunk)"); + if (static_cast(tell()) + diinChunkSize > diinChunkEnd) { + debug("DSDIFF::File::read() -- DIIN Chunk '" + diinChunkName + "' has invalid size (larger than the DIIN chunk)"); setValid(false); break; } @@ -787,9 +741,9 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty chunk.padding = 0; long uPosNotPadded = tell(); - if((uPosNotPadded & 0x01) != 0) { + if ((uPosNotPadded & 0x01) != 0) { ByteVector iByte = readBlock(1); - if((iByte.size() != 1) || (iByte[0] != 0)) + if ((iByte.size() != 1) || (iByte[0] != 0)) // Not well formed, re-seek seek(uPosNotPadded, Beginning); else @@ -798,7 +752,7 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty d->childChunks[DIINChunk].push_back(chunk); } } - else if(d->chunks[i].name == "ID3 " || d->chunks[i].name == "id3 ") { + else if (d->chunks[i].name == "ID3 " || d->chunks[i].name == "id3 ") { d->id3v2TagChunkID = d->chunks[i].name; d->tag.set(ID3v2Index, new ID3v2::Tag(this, d->chunks[i].offset)); d->isID3InPropChunk = false; @@ -806,10 +760,10 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty } } - if(!isValid()) + if (!isValid()) return; - if(d->childChunkIndex[PROPChunk] < 0) { + if (d->childChunkIndex[PROPChunk] < 0) { debug("DSDIFF::File::read() -- no PROP chunk found"); setValid(false); return; @@ -817,13 +771,13 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty // Read properties - unsigned int sampleRate=0; - unsigned short channels=0; + unsigned int sampleRate = 0; + unsigned short channels = 0; - for(unsigned int i = 0; i < d->childChunks[PROPChunk].size(); i++) { - if(d->childChunks[PROPChunk][i].name == "ID3 " || - d->childChunks[PROPChunk][i].name == "id3 ") { - if(d->hasID3v2) { + for (unsigned int i = 0; i < d->childChunks[PROPChunk].size(); i++) { + if (d->childChunks[PROPChunk][i].name == "ID3 " || + d->childChunks[PROPChunk][i].name == "id3 ") { + if (d->hasID3v2) { d->duplicateID3V2chunkIndex = i; // ID3V2 tag has already been found at root level continue; @@ -833,12 +787,12 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty d->isID3InPropChunk = true; d->hasID3v2 = true; } - else if(d->childChunks[PROPChunk][i].name == "FS ") { + else if (d->childChunks[PROPChunk][i].name == "FS ") { // Sample rate seek(d->childChunks[PROPChunk][i].offset); sampleRate = readBlock(4).toUInt(0, 4, bigEndian); } - else if(d->childChunks[PROPChunk][i].name == "CHNL") { + else if (d->childChunks[PROPChunk][i].name == "CHNL") { // Channels seek(d->childChunks[PROPChunk][i].offset); channels = readBlock(2).toShort(0, bigEndian); @@ -849,20 +803,20 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty d->tag.access(DIINIndex, true); - if(d->hasDiin) { - for(unsigned int i = 0; i < d->childChunks[DIINChunk].size(); i++) { - if(d->childChunks[DIINChunk][i].name == "DITI") { + if (d->hasDiin) { + for (unsigned int i = 0; i < d->childChunks[DIINChunk].size(); i++) { + if (d->childChunks[DIINChunk][i].name == "DITI") { seek(d->childChunks[DIINChunk][i].offset); unsigned int titleStrLength = readBlock(4).toUInt(0, 4, bigEndian); - if(titleStrLength <= d->childChunks[DIINChunk][i].size) { + if (titleStrLength <= d->childChunks[DIINChunk][i].size) { ByteVector titleStr = readBlock(titleStrLength); d->tag.access(DIINIndex, false)->setTitle(titleStr); } } - else if(d->childChunks[DIINChunk][i].name == "DIAR") { + else if (d->childChunks[DIINChunk][i].name == "DIAR") { seek(d->childChunks[DIINChunk][i].offset); unsigned int artistStrLength = readBlock(4).toUInt(0, 4, bigEndian); - if(artistStrLength <= d->childChunks[DIINChunk][i].size) { + if (artistStrLength <= d->childChunks[DIINChunk][i].size) { ByteVector artistStr = readBlock(artistStrLength); d->tag.access(DIINIndex, false)->setArtist(artistStr); } @@ -870,33 +824,33 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty } } - if(readProperties) { - if(lengthDSDSamplesTimeChannels == 0) { + if (readProperties) { + if (lengthDSDSamplesTimeChannels == 0) { // DST compressed signal : need to compute length of DSD uncompressed frames - if(dstFrameRate > 0) - lengthDSDSamplesTimeChannels = (unsigned long long) dstNumFrames * - (unsigned long long) sampleRate / - (unsigned long long) dstFrameRate; + if (dstFrameRate > 0) + lengthDSDSamplesTimeChannels = (unsigned long long)dstNumFrames * + (unsigned long long)sampleRate / + (unsigned long long)dstFrameRate; else lengthDSDSamplesTimeChannels = 0; } else { // In DSD uncompressed files, the read number of samples is the total for each channel - if(channels > 0) + if (channels > 0) lengthDSDSamplesTimeChannels /= channels; } int bitrate = 0; - if(lengthDSDSamplesTimeChannels > 0) + if (lengthDSDSamplesTimeChannels > 0) bitrate = (audioDataSizeinBytes * 8 * sampleRate) / lengthDSDSamplesTimeChannels / 1000; d->properties = new Properties(sampleRate, - channels, - lengthDSDSamplesTimeChannels, - bitrate, - propertiesStyle); + channels, + lengthDSDSamplesTimeChannels, + bitrate, + propertiesStyle); } - if(!ID3v2Tag()) { + if (!ID3v2Tag()) { d->tag.access(ID3v2Index, true); // By default, ID3 chunk is at root level d->isID3InPropChunk = false; @@ -905,19 +859,17 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty } void DSDIFF::File::writeChunk(const ByteVector &name, const ByteVector &data, - unsigned long long offset, unsigned long replace, - unsigned int leadingPadding) -{ + unsigned long long offset, unsigned long replace, + unsigned int leadingPadding) { ByteVector combined; - if(leadingPadding) + if (leadingPadding) combined.append(ByteVector(leadingPadding, '\x00')); combined.append(name); combined.append(ByteVector::fromLongLong(data.size(), d->endianness == BigEndian)); combined.append(data); - if((data.size() & 0x01) != 0) + if ((data.size() & 0x01) != 0) combined.append('\x00'); insert(combined, offset, replace); } - diff --git a/3rdparty/taglib/dsdiff/dsdifffile.h b/3rdparty/taglib/dsdiff/dsdifffile.h index e881c7cdb..f68cdcf1d 100644 --- a/3rdparty/taglib/dsdiff/dsdifffile.h +++ b/3rdparty/taglib/dsdiff/dsdifffile.h @@ -34,9 +34,9 @@ namespace Strawberry_TagLib { namespace TagLib { - //! An implementation of DSDIFF metadata +//! An implementation of DSDIFF metadata - /*! +/*! * This is implementation of DSDIFF metadata. * * This supports an ID3v2 tag as well as reading stream from the ID3 RIFF @@ -48,46 +48,44 @@ namespace TagLib { * In addition, title and artist info are stored as part of the standard */ - namespace DSDIFF { +namespace DSDIFF { - //! An implementation of TagLib::File with DSDIFF specific methods +//! An implementation of TagLib::File with DSDIFF specific methods - /*! +/*! * This implements and provides an interface for DSDIFF files to the * TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing * the abstract TagLib::File API as well as providing some additional * information specific to DSDIFF files. */ - class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File - { - public: - - /*! +class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File { + public: + /*! * This set of flags is used for various operations and is suitable for * being OR-ed together. */ - enum TagTypes { - //! Empty set. Matches no tag types. - NoTags = 0x0000, - //! Matches DIIN tags. - DIIN = 0x0002, - //! Matches ID3v1 tags. - ID3v2 = 0x0002, - //! Matches all tag types. - AllTags = 0xffff - }; + enum TagTypes { + //! Empty set. Matches no tag types. + NoTags = 0x0000, + //! Matches DIIN tags. + DIIN = 0x0002, + //! Matches ID3v1 tags. + ID3v2 = 0x0002, + //! Matches all tag types. + AllTags = 0xffff + }; - /*! + /*! * Constructs an DSDIFF file from \a file. If \a readProperties is true * the file's audio properties will also be read. * * \note In the current implementation, \a propertiesStyle is ignored. */ - File(FileName file, bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(FileName file, bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Constructs an DSDIFF file from \a stream. If \a readProperties is true * the file's audio properties will also be read. * @@ -96,15 +94,15 @@ namespace TagLib { * * \note In the current implementation, \a propertiesStyle is ignored. */ - File(IOStream *stream, bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(IOStream *stream, bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Destroys this instance of the File. */ - virtual ~File(); + virtual ~File(); - /*! + /*! * Returns a pointer to a tag that is the union of the ID3v2 and DIIN * tags. The ID3v2 tag is given priority in reading the information -- if * requested information exists in both the ID3v2 tag and the ID3v1 tag, @@ -120,9 +118,9 @@ namespace TagLib { * \see ID3v2Tag() * \see DIINTag() */ - virtual Tag *tag() const; + virtual Tag *tag() const; - /*! + /*! * Returns the ID3V2 Tag for this file. * * \note This always returns a valid pointer regardless of whether or not @@ -131,35 +129,35 @@ namespace TagLib { * * \see hasID3v2Tag() */ - ID3v2::Tag *ID3v2Tag(bool create = false) const; + ID3v2::Tag *ID3v2Tag(bool create = false) const; - /*! + /*! * Returns the DSDIFF DIIN Tag for this file * */ - DSDIFF::DIIN::Tag *DIINTag(bool create = false) const; + DSDIFF::DIIN::Tag *DIINTag(bool create = false) const; - /*! + /*! * Implements the unified property interface -- export function. * This method forwards to ID3v2::Tag::properties(). */ - PropertyMap properties() const; + PropertyMap properties() const; - void removeUnsupportedProperties(const StringList &properties); + void removeUnsupportedProperties(const StringList &properties); - /*! + /*! * Implements the unified property interface -- import function. * This method forwards to ID3v2::Tag::setProperties(). */ - PropertyMap setProperties(const PropertyMap &); + PropertyMap setProperties(const PropertyMap &); - /*! + /*! * Returns the AIFF::Properties for this file. If no audio properties * were read then this will return a null pointer. */ - virtual Properties *audioProperties() const; + virtual Properties *audioProperties() const; - /*! + /*! * Save the file. If at least one tag -- ID3v1 or DIIN -- exists this * will duplicate its content into the other tag. This returns true * if saving was successful. @@ -174,71 +172,72 @@ namespace TagLib { * * \see save(int tags) */ - virtual bool save(); + virtual bool save(); - /*! + /*! * Save the file. If \a strip is specified, it is possible to choose if * tags not specified in \a tags should be stripped from the file or * retained. With \a version, it is possible to specify whether ID3v2.4 * or ID3v2.3 should be used. */ - bool save(TagTypes tags, StripTags strip = StripOthers, ID3v2::Version version = ID3v2::v4); + bool save(TagTypes tags, StripTags strip = StripOthers, ID3v2::Version version = ID3v2::v4); - /*! + /*! * This will strip the tags that match the OR-ed together TagTypes from the * file. By default it strips all tags. It returns true if the tags are * successfully stripped. * * \note This will update the file immediately. */ - void strip(TagTypes tags = AllTags); + void strip(TagTypes tags = AllTags); - /*! + /*! * Returns whether or not the file on disk actually has an ID3v2 tag. * * \see ID3v2Tag() */ - bool hasID3v2Tag() const; + bool hasID3v2Tag() const; - /*! + /*! * Returns whether or not the file on disk actually has the DSDIFF * title and artist tags. * * \see DIINTag() */ - bool hasDIINTag() const; + bool hasDIINTag() const; - /*! + /*! * Returns whether or not the given \a stream can be opened as a DSDIFF * file. * * \note This method is designed to do a quick check. The result may * not necessarily be correct. */ - static bool isSupported(IOStream *stream); + static bool isSupported(IOStream *stream); - protected: - enum Endianness { BigEndian, LittleEndian }; + protected: + enum Endianness { BigEndian, + LittleEndian }; - File(FileName file, Endianness endianness); - File(IOStream *stream, Endianness endianness); + File(FileName file, Endianness endianness); + File(IOStream *stream, Endianness endianness); - private: - File(const File &); - File &operator=(const File &); + private: + File(const File &); + File &operator=(const File &); - void removeRootChunk(const ByteVector &id); - void removeRootChunk(unsigned int chunk); - void removeChildChunk(unsigned int i, unsigned int chunk); + void removeRootChunk(const ByteVector &id); + void removeRootChunk(unsigned int chunk); + void removeChildChunk(unsigned int i, unsigned int chunk); - /*! + /*! * Sets the data for the the specified chunk at root level to \a data. * * \warning This will update the file immediately. */ - void setRootChunkData(unsigned int i, const ByteVector &data); + void setRootChunkData(unsigned int i, const ByteVector &data); - /*! + /*! * Sets the data for the root-level chunk \a name to \a data. * If a root-level chunk with the given name already exists * it will be overwritten, otherwise it will be @@ -246,19 +245,19 @@ namespace TagLib { * * \warning This will update the file immediately. */ - void setRootChunkData(const ByteVector &name, const ByteVector &data); + void setRootChunkData(const ByteVector &name, const ByteVector &data); - /*! + /*! * Sets the data for the the specified child chunk to \a data. * * If data is null, then remove the chunk * * \warning This will update the file immediately. */ - void setChildChunkData(unsigned int i, const ByteVector &data, - unsigned int childChunkNum); + void setChildChunkData(unsigned int i, const ByteVector &data, + unsigned int childChunkNum); - /*! + /*! * Sets the data for the child chunk \a name to \a data. If a chunk with * the given name already exists it will be overwritten, otherwise it will * be created after the existing chunks inside child chunk. @@ -267,22 +266,21 @@ namespace TagLib { * * \warning This will update the file immediately. */ - void setChildChunkData(const ByteVector &name, const ByteVector &data, - unsigned int childChunkNum); + void setChildChunkData(const ByteVector &name, const ByteVector &data, + unsigned int childChunkNum); - void updateRootChunksStructure(unsigned int startingChunk); + void updateRootChunksStructure(unsigned int startingChunk); - void read(bool readProperties, Properties::ReadStyle propertiesStyle); - void writeChunk(const ByteVector &name, const ByteVector &data, - unsigned long long offset, unsigned long replace = 0, - unsigned int leadingPadding = 0); + void read(bool readProperties, Properties::ReadStyle propertiesStyle); + void writeChunk(const ByteVector &name, const ByteVector &data, + unsigned long long offset, unsigned long replace = 0, + unsigned int leadingPadding = 0); - class FilePrivate; - FilePrivate *d; - }; - } -} -} + class FilePrivate; + FilePrivate *d; +}; +} // namespace DSDIFF +} // namespace TagLib +} // namespace Strawberry_TagLib #endif - diff --git a/3rdparty/taglib/dsdiff/dsdiffproperties.cpp b/3rdparty/taglib/dsdiff/dsdiffproperties.cpp index a51d973ef..2f6d62cfe 100644 --- a/3rdparty/taglib/dsdiff/dsdiffproperties.cpp +++ b/3rdparty/taglib/dsdiff/dsdiffproperties.cpp @@ -30,17 +30,14 @@ using namespace Strawberry_TagLib::TagLib; -class DSDIFF::Properties::PropertiesPrivate -{ -public: - PropertiesPrivate() : - length(0), - bitrate(0), - sampleRate(0), - channels(0), - sampleWidth(0), - sampleCount(0) - { +class DSDIFF::Properties::PropertiesPrivate { + public: + PropertiesPrivate() : length(0), + bitrate(0), + sampleRate(0), + channels(0), + sampleWidth(0), + sampleCount(0) { } int length; @@ -56,65 +53,52 @@ public: //////////////////////////////////////////////////////////////////////////////// DSDIFF::Properties::Properties(const unsigned int sampleRate, - const unsigned short channels, - const unsigned long long samplesCount, - const int bitrate, - ReadStyle style) : AudioProperties(style) -{ + const unsigned short channels, + const unsigned long long samplesCount, + const int bitrate, + ReadStyle style) : AudioProperties(style) { d = new PropertiesPrivate; - d->channels = channels; + d->channels = channels; d->sampleCount = samplesCount; d->sampleWidth = 1; - d->sampleRate = sampleRate; - d->bitrate = bitrate; - d->length = d->sampleRate > 0 - ? static_cast((d->sampleCount * 1000.0) / d->sampleRate + 0.5) - : 0; + d->sampleRate = sampleRate; + d->bitrate = bitrate; + d->length = d->sampleRate > 0 ? static_cast((d->sampleCount * 1000.0) / d->sampleRate + 0.5) : 0; } -DSDIFF::Properties::~Properties() -{ +DSDIFF::Properties::~Properties() { delete d; } -int DSDIFF::Properties::length() const -{ +int DSDIFF::Properties::length() const { return lengthInSeconds(); } -int DSDIFF::Properties::lengthInSeconds() const -{ +int DSDIFF::Properties::lengthInSeconds() const { return d->length / 1000; } -int DSDIFF::Properties::lengthInMilliseconds() const -{ +int DSDIFF::Properties::lengthInMilliseconds() const { return d->length; } -int DSDIFF::Properties::bitrate() const -{ +int DSDIFF::Properties::bitrate() const { return d->bitrate; } -int DSDIFF::Properties::sampleRate() const -{ +int DSDIFF::Properties::sampleRate() const { return d->sampleRate; } -int DSDIFF::Properties::channels() const -{ +int DSDIFF::Properties::channels() const { return d->channels; } -int DSDIFF::Properties::bitsPerSample() const -{ +int DSDIFF::Properties::bitsPerSample() const { return d->sampleWidth; } -long long DSDIFF::Properties::sampleCount() const -{ +long long DSDIFF::Properties::sampleCount() const { return d->sampleCount; } - diff --git a/3rdparty/taglib/dsdiff/dsdiffproperties.h b/3rdparty/taglib/dsdiff/dsdiffproperties.h index d2d852338..27785c5e5 100644 --- a/3rdparty/taglib/dsdiff/dsdiffproperties.h +++ b/3rdparty/taglib/dsdiff/dsdiffproperties.h @@ -31,55 +31,53 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace DSDIFF { +namespace DSDIFF { - class File; +class File; - //! An implementation of audio property reading for DSDIFF +//! An implementation of audio property reading for DSDIFF - /*! +/*! * This reads the data from an DSDIFF stream found in the AudioProperties * API. */ - class TAGLIB_EXPORT Properties : public AudioProperties - { - public: - /*! +class TAGLIB_EXPORT Properties : public AudioProperties { + public: + /*! * Create an instance of DSDIFF::Properties with the data read from the * ByteVector \a data. */ - Properties(const unsigned int sampleRate, const unsigned short channels, - const unsigned long long samplesCount, const int bitrate, - ReadStyle style); + Properties(const unsigned int sampleRate, const unsigned short channels, + const unsigned long long samplesCount, const int bitrate, + ReadStyle style); - /*! + /*! * Destroys this DSDIFF::Properties instance. */ - virtual ~Properties(); + virtual ~Properties(); - // Reimplementations. + // Reimplementations. - virtual int length() const; - virtual int lengthInSeconds() const; - virtual int lengthInMilliseconds() const; - virtual int bitrate() const; - virtual int sampleRate() const; - virtual int channels() const; + virtual int length() const; + virtual int lengthInSeconds() const; + virtual int lengthInMilliseconds() const; + virtual int bitrate() const; + virtual int sampleRate() const; + virtual int channels() const; - int bitsPerSample() const; - long long sampleCount() const; + int bitsPerSample() const; + long long sampleCount() const; - private: - Properties(const Properties &); - Properties &operator=(const Properties &); + private: + Properties(const Properties &); + Properties &operator=(const Properties &); - class PropertiesPrivate; - PropertiesPrivate *d; - }; - } -} -} + class PropertiesPrivate; + PropertiesPrivate *d; +}; +} // namespace DSDIFF +} // namespace TagLib +} // namespace Strawberry_TagLib #endif - diff --git a/3rdparty/taglib/dsf/dsffile.cpp b/3rdparty/taglib/dsf/dsffile.cpp index c320ea2a5..6dfed0653 100644 --- a/3rdparty/taglib/dsf/dsffile.cpp +++ b/3rdparty/taglib/dsf/dsffile.cpp @@ -36,19 +36,15 @@ using namespace Strawberry_TagLib::TagLib; // The DSF specification is located at http://dsd-guide.com/sites/default/files/white-papers/DSFFileFormatSpec_E.pdf -class DSF::File::FilePrivate -{ -public: - FilePrivate() : - fileSize(0), - metadataOffset(0), - properties(nullptr), - tag(nullptr) - { +class DSF::File::FilePrivate { + public: + FilePrivate() : fileSize(0), + metadataOffset(0), + properties(nullptr), + tag(nullptr) { } - ~FilePrivate() - { + ~FilePrivate() { delete properties; delete tag; } @@ -63,11 +59,10 @@ public: // static members //////////////////////////////////////////////////////////////////////////////// -bool DSF::File::isSupported(IOStream *stream) -{ - // A DSF file has to start with "DSD " - const ByteVector id = Utils::readHeader(stream, 4, false); - return id.startsWith("DSD "); +bool DSF::File::isSupported(IOStream *stream) { + // A DSF file has to start with "DSD " + const ByteVector id = Utils::readHeader(stream, 4, false); + return id.startsWith("DSD "); } //////////////////////////////////////////////////////////////////////////////// @@ -75,73 +70,63 @@ bool DSF::File::isSupported(IOStream *stream) //////////////////////////////////////////////////////////////////////////////// DSF::File::File(FileName file, bool readProperties, - Properties::ReadStyle propertiesStyle) : - Strawberry_TagLib::TagLib::File(file), - d(new FilePrivate()) -{ - if(isOpen()) + Properties::ReadStyle propertiesStyle) : Strawberry_TagLib::TagLib::File(file), + d(new FilePrivate()) { + if (isOpen()) read(readProperties, propertiesStyle); } DSF::File::File(IOStream *stream, bool readProperties, - Properties::ReadStyle propertiesStyle) : - Strawberry_TagLib::TagLib::File(stream), - d(new FilePrivate()) -{ - if(isOpen()) + Properties::ReadStyle propertiesStyle) : Strawberry_TagLib::TagLib::File(stream), + d(new FilePrivate()) { + if (isOpen()) read(readProperties, propertiesStyle); } -DSF::File::~File() -{ +DSF::File::~File() { delete d; } -ID3v2::Tag *DSF::File::tag() const -{ +ID3v2::Tag *DSF::File::tag() const { return d->tag; } -PropertyMap DSF::File::properties() const -{ +PropertyMap DSF::File::properties() const { return d->tag->properties(); } -PropertyMap DSF::File::setProperties(const PropertyMap &properties) -{ +PropertyMap DSF::File::setProperties(const PropertyMap &properties) { return d->tag->setProperties(properties); } -DSF::Properties *DSF::File::audioProperties() const -{ +DSF::Properties *DSF::File::audioProperties() const { return d->properties; } -bool DSF::File::save() -{ - if(readOnly()) { +bool DSF::File::save() { + if (readOnly()) { debug("DSF::File::save() -- File is read only."); return false; } - if(!isValid()) { + if (!isValid()) { debug("DSF::File::save() -- Trying to save invalid file."); return false; } // Three things must be updated: the file size, the tag data, and the metadata offset - if(d->tag->isEmpty()) { + if (d->tag->isEmpty()) { long long newFileSize = d->metadataOffset ? d->metadataOffset : d->fileSize; // Update the file size - if(d->fileSize != newFileSize) { + if (d->fileSize != newFileSize) { insert(ByteVector::fromLongLong(newFileSize, false), 12, 8); d->fileSize = newFileSize; } // Update the metadata offset to 0 since there is no longer a tag - if(d->metadataOffset) { + if (d->metadataOffset) { insert(ByteVector::fromLongLong(0ULL, false), 20, 8); d->metadataOffset = 0; } @@ -157,13 +142,13 @@ bool DSF::File::save() long long oldTagSize = d->fileSize - newMetadataOffset; // Update the file size - if(d->fileSize != newFileSize) { + if (d->fileSize != newFileSize) { insert(ByteVector::fromLongLong(newFileSize, false), 12, 8); d->fileSize = newFileSize; } // Update the metadata offset - if(d->metadataOffset != newMetadataOffset) { + if (d->metadataOffset != newMetadataOffset) { insert(ByteVector::fromLongLong(newMetadataOffset, false), 20, 8); d->metadataOffset = newMetadataOffset; } @@ -180,14 +165,13 @@ bool DSF::File::save() //////////////////////////////////////////////////////////////////////////////// -void DSF::File::read(bool, Properties::ReadStyle propertiesStyle) -{ +void DSF::File::read(bool, Properties::ReadStyle propertiesStyle) { // A DSF file consists of four chunks: DSD chunk, format chunk, data chunk, and metadata chunk // The file format is not chunked in the sense of a RIFF File, though // DSD chunk ByteVector chunkName = readBlock(4); - if(chunkName != "DSD ") { + if (chunkName != "DSD ") { debug("DSF::File::read() -- Not a DSF file."); setValid(false); return; @@ -196,7 +180,7 @@ void DSF::File::read(bool, Properties::ReadStyle propertiesStyle) long long chunkSize = readBlock(8).toLongLong(false); // Integrity check - if(28 != chunkSize) { + if (28 != chunkSize) { debug("DSF::File::read() -- File is corrupted, wrong chunk size"); setValid(false); return; @@ -205,7 +189,7 @@ void DSF::File::read(bool, Properties::ReadStyle propertiesStyle) d->fileSize = readBlock(8).toLongLong(false); // File is malformed or corrupted - if(d->fileSize != length()) { + if (d->fileSize != length()) { debug("DSF::File::read() -- File is corrupted wrong length"); setValid(false); return; @@ -214,7 +198,7 @@ void DSF::File::read(bool, Properties::ReadStyle propertiesStyle) d->metadataOffset = readBlock(8).toLongLong(false); // File is malformed or corrupted - if(d->metadataOffset > d->fileSize) { + if (d->metadataOffset > d->fileSize) { debug("DSF::File::read() -- Invalid metadata offset."); setValid(false); return; @@ -222,7 +206,7 @@ void DSF::File::read(bool, Properties::ReadStyle propertiesStyle) // Format chunk chunkName = readBlock(4); - if(chunkName != "fmt ") { + if (chunkName != "fmt ") { debug("DSF::File::read() -- Missing 'fmt ' chunk."); setValid(false); return; @@ -235,9 +219,8 @@ void DSF::File::read(bool, Properties::ReadStyle propertiesStyle) // Skip the data chunk // A metadata offset of 0 indicates the absence of an ID3v2 tag - if(0 == d->metadataOffset) + if (0 == d->metadataOffset) d->tag = new ID3v2::Tag(); else d->tag = new ID3v2::Tag(this, d->metadataOffset); } - diff --git a/3rdparty/taglib/dsf/dsffile.h b/3rdparty/taglib/dsf/dsffile.h index 06050624b..be53e34f3 100644 --- a/3rdparty/taglib/dsf/dsffile.h +++ b/3rdparty/taglib/dsf/dsffile.h @@ -33,98 +33,96 @@ namespace Strawberry_TagLib { namespace TagLib { - //! An implementation of DSF metadata +//! An implementation of DSF metadata - /*! +/*! * This is implementation of DSF metadata. * * This supports an ID3v2 tag as well as properties from the file. */ - namespace DSF { +namespace DSF { - //! An implementation of Strawberry_TagLib::TagLib::File with DSF specific methods +//! An implementation of Strawberry_TagLib::TagLib::File with DSF specific methods - /*! +/*! * This implements and provides an interface for DSF files to the * Strawberry_TagLib::TagLib::Tag and Strawberry_TagLib::TagLib::AudioProperties interfaces by way of implementing * the abstract Strawberry_TagLib::TagLib::File API as well as providing some additional * information specific to DSF files. */ - class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File - { - public: - /*! +class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File { + public: + /*! * Constructs an DSF file from \a file. If \a readProperties is true the * file's audio properties will also be read using \a propertiesStyle. If * false, \a propertiesStyle is ignored. */ - File(FileName file, bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(FileName file, bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Constructs an DSF file from \a file. If \a readProperties is true the * file's audio properties will also be read using \a propertiesStyle. If * false, \a propertiesStyle is ignored. */ - File(IOStream *stream, bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(IOStream *stream, bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Destroys this instance of the File. */ - virtual ~File(); + virtual ~File(); - /*! + /*! * Returns the Tag for this file. */ - ID3v2::Tag *tag() const; + ID3v2::Tag *tag() const; - /*! + /*! * Implements the unified property interface -- export function. * This method forwards to ID3v2::Tag::properties(). */ - PropertyMap properties() const; + PropertyMap properties() const; - /*! + /*! * Implements the unified property interface -- import function. * This method forwards to ID3v2::Tag::setProperties(). */ - PropertyMap setProperties(const PropertyMap &); + PropertyMap setProperties(const PropertyMap &); - /*! + /*! * Returns the DSF::AudioProperties for this file. If no audio properties * were read then this will return a null pointer. */ - virtual Properties *audioProperties() const; + virtual Properties *audioProperties() const; - /*! + /*! * Saves the file. */ - virtual bool save(); + virtual bool save(); - /*! + /*! * Returns whether or not the given \a stream can be opened as a DSF * file. * * \note This method is designed to do a quick check. The result may * not necessarily be correct. */ - static bool isSupported(IOStream *stream); + static bool isSupported(IOStream *stream); - private: - File(const File &); - File &operator=(const File &); + private: + File(const File &); + File &operator=(const File &); - void read(bool readProperties, Properties::ReadStyle propertiesStyle); + void read(bool readProperties, Properties::ReadStyle propertiesStyle); - class FilePrivate; - FilePrivate *d; - }; - } -} -} + class FilePrivate; + FilePrivate *d; +}; +} // namespace DSF +} // namespace TagLib +} // namespace Strawberry_TagLib #endif - diff --git a/3rdparty/taglib/dsf/dsfproperties.cpp b/3rdparty/taglib/dsf/dsfproperties.cpp index 5b9423592..c24dc916b 100644 --- a/3rdparty/taglib/dsf/dsfproperties.cpp +++ b/3rdparty/taglib/dsf/dsfproperties.cpp @@ -30,21 +30,18 @@ using namespace Strawberry_TagLib::TagLib; -class DSF::Properties::PropertiesPrivate -{ -public: - PropertiesPrivate() : - formatVersion(0), - formatID(0), - channelType(0), - channelNum(0), - samplingFrequency(0), - bitsPerSample(0), - sampleCount(0), - blockSizePerChannel(0), - bitrate(0), - length(0) - { +class DSF::Properties::PropertiesPrivate { + public: + PropertiesPrivate() : formatVersion(0), + formatID(0), + channelType(0), + channelNum(0), + samplingFrequency(0), + bitsPerSample(0), + sampleCount(0), + blockSizePerChannel(0), + bitrate(0), + length(0) { } // Nomenclature is from DSF file format specification @@ -66,75 +63,61 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -DSF::Properties::Properties(const ByteVector &data, ReadStyle style) : Strawberry_TagLib::TagLib::AudioProperties(style) -{ +DSF::Properties::Properties(const ByteVector &data, ReadStyle style) : Strawberry_TagLib::TagLib::AudioProperties(style) { d = new PropertiesPrivate; read(data); } -DSF::Properties::~Properties() -{ +DSF::Properties::~Properties() { delete d; } -int DSF::Properties::length() const -{ +int DSF::Properties::length() const { return lengthInSeconds(); } -int DSF::Properties::lengthInSeconds() const -{ +int DSF::Properties::lengthInSeconds() const { return d->length / 1000; } -int DSF::Properties::lengthInMilliseconds() const -{ +int DSF::Properties::lengthInMilliseconds() const { return d->length; } -int DSF::Properties::bitrate() const -{ +int DSF::Properties::bitrate() const { return d->bitrate; } -int DSF::Properties::sampleRate() const -{ +int DSF::Properties::sampleRate() const { return d->samplingFrequency; } -int DSF::Properties::channels() const -{ +int DSF::Properties::channels() const { return d->channelNum; } // DSF specific -int DSF::Properties::formatVersion() const -{ +int DSF::Properties::formatVersion() const { return d->formatVersion; } -int DSF::Properties::formatID() const -{ +int DSF::Properties::formatID() const { return d->formatID; } -int DSF::Properties::channelType() const -{ +int DSF::Properties::channelType() const { return d->channelType; } -int DSF::Properties::bitsPerSample() const -{ +int DSF::Properties::bitsPerSample() const { return d->bitsPerSample; } -long long DSF::Properties::sampleCount() const -{ +long long DSF::Properties::sampleCount() const { return d->sampleCount; } -int DSF::Properties::blockSizePerChannel() const -{ +int DSF::Properties::blockSizePerChannel() const { return d->blockSizePerChannel; } @@ -142,20 +125,16 @@ int DSF::Properties::blockSizePerChannel() const // private members //////////////////////////////////////////////////////////////////////////////// -void DSF::Properties::read(const ByteVector &data) -{ - d->formatVersion = data.toUInt(0U,false); - d->formatID = data.toUInt(4U,false); - d->channelType = data.toUInt(8U,false); - d->channelNum = data.toUInt(12U,false); - d->samplingFrequency = data.toUInt(16U,false); - d->bitsPerSample = data.toUInt(20U,false); - d->sampleCount = data.toLongLong(24U,false); - d->blockSizePerChannel = data.toUInt(32U,false); +void DSF::Properties::read(const ByteVector &data) { + d->formatVersion = data.toUInt(0U, false); + d->formatID = data.toUInt(4U, false); + d->channelType = data.toUInt(8U, false); + d->channelNum = data.toUInt(12U, false); + d->samplingFrequency = data.toUInt(16U, false); + d->bitsPerSample = data.toUInt(20U, false); + d->sampleCount = data.toLongLong(24U, false); + d->blockSizePerChannel = data.toUInt(32U, false); - d->bitrate - = static_cast((d->samplingFrequency * d->bitsPerSample * d->channelNum) / 1000.0 + 0.5); - d->length - = d->samplingFrequency > 0 ? static_cast(d->sampleCount * 1000.0 / d->samplingFrequency + 0.5) : 0; + d->bitrate = static_cast((d->samplingFrequency * d->bitsPerSample * d->channelNum) / 1000.0 + 0.5); + d->length = d->samplingFrequency > 0 ? static_cast(d->sampleCount * 1000.0 / d->samplingFrequency + 0.5) : 0; } - diff --git a/3rdparty/taglib/dsf/dsfproperties.h b/3rdparty/taglib/dsf/dsfproperties.h index 26ae36a2f..f3c2492fd 100644 --- a/3rdparty/taglib/dsf/dsfproperties.h +++ b/3rdparty/taglib/dsf/dsfproperties.h @@ -31,64 +31,62 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace DSF { +namespace DSF { - class File; +class File; - //! An implementation of audio property reading for DSF +//! An implementation of audio property reading for DSF - /*! +/*! * This reads the data from a DSF stream found in the AudioProperties * API. */ - class TAGLIB_EXPORT Properties : public Strawberry_TagLib::TagLib::AudioProperties - { - public: - /*! +class TAGLIB_EXPORT Properties : public Strawberry_TagLib::TagLib::AudioProperties { + public: + /*! * Create an instance of DSF::AudioProperties with the data read from the * ByteVector \a data. */ - Properties(const ByteVector &data, ReadStyle style); + Properties(const ByteVector &data, ReadStyle style); - /*! + /*! * Destroys this DSF::AudioProperties instance. */ - virtual ~Properties(); + virtual ~Properties(); - // Reimplementations. + // Reimplementations. - virtual int length() const; - virtual int lengthInSeconds() const; - virtual int lengthInMilliseconds() const; - virtual int bitrate() const; - virtual int sampleRate() const; - virtual int channels() const; + virtual int length() const; + virtual int lengthInSeconds() const; + virtual int lengthInMilliseconds() const; + virtual int bitrate() const; + virtual int sampleRate() const; + virtual int channels() const; - int formatVersion() const; - int formatID() const; + int formatVersion() const; + int formatID() const; - /*! + /*! * Channel type values: 1 = mono, 2 = stereo, 3 = 3 channels, * 4 = quad, 5 = 4 channels, 6 = 5 channels, 7 = 5.1 channels */ - int channelType() const; - int bitsPerSample() const; - long long sampleCount() const; - int blockSizePerChannel() const; + int channelType() const; + int bitsPerSample() const; + long long sampleCount() const; + int blockSizePerChannel() const; - private: - Properties(const Properties &); - Properties &operator=(const Properties &); + private: + Properties(const Properties &); + Properties &operator=(const Properties &); - void read(const ByteVector &data); + void read(const ByteVector &data); - class PropertiesPrivate; - PropertiesPrivate *d; - }; - } -} -} + class PropertiesPrivate; + PropertiesPrivate *d; +}; +} // namespace DSF +} // namespace TagLib +} // namespace Strawberry_TagLib #endif - diff --git a/3rdparty/taglib/fileref.cpp b/3rdparty/taglib/fileref.cpp index e81b78936..922bdf52e 100644 --- a/3rdparty/taglib/fileref.cpp +++ b/3rdparty/taglib/fileref.cpp @@ -57,237 +57,230 @@ using namespace Strawberry_TagLib::TagLib; -namespace -{ - typedef List ResolverList; - ResolverList fileTypeResolvers; +namespace { +typedef List ResolverList; +ResolverList fileTypeResolvers; - // Detect the file type by user-defined resolvers. +// Detect the file type by user-defined resolvers. - File *detectByResolvers(FileName fileName, bool readAudioProperties, - AudioProperties::ReadStyle audioPropertiesStyle) - { - ResolverList::ConstIterator it = fileTypeResolvers.begin(); - for(; it != fileTypeResolvers.end(); ++it) { - File *file = (*it)->createFile(fileName, readAudioProperties, audioPropertiesStyle); - if(file) - return file; - } - - return nullptr; - } - - // Detect the file type based on the file extension. - - File* detectByExtension(IOStream *stream, bool readAudioProperties, - AudioProperties::ReadStyle audioPropertiesStyle) - { -#ifdef _WIN32 - const String s = stream->name().toString(); -#else - const String s(stream->name()); -#endif - - String ext; - const int pos = s.rfind("."); - if(pos != -1) - ext = s.substr(pos + 1).upper(); - - // If this list is updated, the method defaultFileExtensions() should also be - // updated. However at some point that list should be created at the same time - // that a default file type resolver is created. - - if(ext.isEmpty()) - return nullptr; - - // .oga can be any audio in the Ogg container. So leave it to content-based detection. - - if(ext == "MP3") - return new MPEG::File(stream, ID3v2::FrameFactory::instance(), readAudioProperties, audioPropertiesStyle); - if(ext == "OGG") - return new Ogg::Vorbis::File(stream, readAudioProperties, audioPropertiesStyle); - if(ext == "FLAC") - return new FLAC::File(stream, ID3v2::FrameFactory::instance(), readAudioProperties, audioPropertiesStyle); - if(ext == "MPC") - return new MPC::File(stream, readAudioProperties, audioPropertiesStyle); - if(ext == "WV") - return new WavPack::File(stream, readAudioProperties, audioPropertiesStyle); - if(ext == "SPX") - return new Ogg::Speex::File(stream, readAudioProperties, audioPropertiesStyle); - if(ext == "OPUS") - return new Ogg::Opus::File(stream, readAudioProperties, audioPropertiesStyle); - if(ext == "TTA") - return new TrueAudio::File(stream, readAudioProperties, audioPropertiesStyle); - if(ext == "M4A" || ext == "M4R" || ext == "M4B" || ext == "M4P" || ext == "MP4" || ext == "3G2" || ext == "M4V") - return new MP4::File(stream, readAudioProperties, audioPropertiesStyle); - if(ext == "WMA" || ext == "ASF") - return new ASF::File(stream, readAudioProperties, audioPropertiesStyle); - if(ext == "AIF" || ext == "AIFF" || ext == "AFC" || ext == "AIFC") - return new RIFF::AIFF::File(stream, readAudioProperties, audioPropertiesStyle); - if(ext == "WAV") - return new RIFF::WAV::File(stream, readAudioProperties, audioPropertiesStyle); - if(ext == "APE") - return new APE::File(stream, readAudioProperties, audioPropertiesStyle); - // module, nst and wow are possible but uncommon extensions - if(ext == "MOD" || ext == "MODULE" || ext == "NST" || ext == "WOW") - return new Mod::File(stream, readAudioProperties, audioPropertiesStyle); - if(ext == "S3M") - return new S3M::File(stream, readAudioProperties, audioPropertiesStyle); - if(ext == "IT") - return new IT::File(stream, readAudioProperties, audioPropertiesStyle); - if(ext == "XM") - return new XM::File(stream, readAudioProperties, audioPropertiesStyle); - if(ext == "DFF" || ext == "DSDIFF") - return new DSDIFF::File(stream, readAudioProperties, audioPropertiesStyle); - if(ext == "DSF") - return new DSF::File(stream, readAudioProperties, audioPropertiesStyle); - - return nullptr; - } - - // Detect the file type based on the actual content of the stream. - - File *detectByContent(IOStream *stream, bool readAudioProperties, - AudioProperties::ReadStyle audioPropertiesStyle) - { - File *file = 0; - - if(MPEG::File::isSupported(stream)) - file = new MPEG::File(stream, ID3v2::FrameFactory::instance(), readAudioProperties, audioPropertiesStyle); - else if(Ogg::Vorbis::File::isSupported(stream)) - file = new Ogg::Vorbis::File(stream, readAudioProperties, audioPropertiesStyle); - else if(Ogg::FLAC::File::isSupported(stream)) - file = new Ogg::FLAC::File(stream, readAudioProperties, audioPropertiesStyle); - else if(FLAC::File::isSupported(stream)) - file = new FLAC::File(stream, ID3v2::FrameFactory::instance(), readAudioProperties, audioPropertiesStyle); - else if(MPC::File::isSupported(stream)) - file = new MPC::File(stream, readAudioProperties, audioPropertiesStyle); - else if(WavPack::File::isSupported(stream)) - file = new WavPack::File(stream, readAudioProperties, audioPropertiesStyle); - else if(Ogg::Speex::File::isSupported(stream)) - file = new Ogg::Speex::File(stream, readAudioProperties, audioPropertiesStyle); - else if(Ogg::Opus::File::isSupported(stream)) - file = new Ogg::Opus::File(stream, readAudioProperties, audioPropertiesStyle); - else if(TrueAudio::File::isSupported(stream)) - file = new TrueAudio::File(stream, readAudioProperties, audioPropertiesStyle); - else if(MP4::File::isSupported(stream)) - file = new MP4::File(stream, readAudioProperties, audioPropertiesStyle); - else if(ASF::File::isSupported(stream)) - file = new ASF::File(stream, readAudioProperties, audioPropertiesStyle); - else if(RIFF::AIFF::File::isSupported(stream)) - file = new RIFF::AIFF::File(stream, readAudioProperties, audioPropertiesStyle); - else if(RIFF::WAV::File::isSupported(stream)) - file = new RIFF::WAV::File(stream, readAudioProperties, audioPropertiesStyle); - else if(APE::File::isSupported(stream)) - file = new APE::File(stream, readAudioProperties, audioPropertiesStyle); - else if(DSDIFF::File::isSupported(stream)) - file = new DSDIFF::File(stream, readAudioProperties, audioPropertiesStyle); - else if(DSF::File::isSupported(stream)) - file = new DSF::File(stream, readAudioProperties, audioPropertiesStyle); - - // isSupported() only does a quick check, so double check the file here. - - if(file) { - if(file->isValid()) - return file; - else - delete file; - } - - return nullptr; - } - - // Internal function that supports FileRef::create(). - // This looks redundant, but necessary in order not to change the previous - // behavior of FileRef::create(). - - File* createInternal(FileName fileName, bool readAudioProperties, - AudioProperties::ReadStyle audioPropertiesStyle) - { - File *file = detectByResolvers(fileName, readAudioProperties, audioPropertiesStyle); - if(file) +File *detectByResolvers(FileName fileName, bool readAudioProperties, + AudioProperties::ReadStyle audioPropertiesStyle) { + ResolverList::ConstIterator it = fileTypeResolvers.begin(); + for (; it != fileTypeResolvers.end(); ++it) { + File *file = (*it)->createFile(fileName, readAudioProperties, audioPropertiesStyle); + if (file) return file; - -#ifdef _WIN32 - const String s = fileName.toString(); -#else - const String s(fileName); -#endif - - String ext; - const int pos = s.rfind("."); - if(pos != -1) - ext = s.substr(pos + 1).upper(); - - if(ext.isEmpty()) - return nullptr; - - if(ext == "MP3") - return new MPEG::File(fileName, ID3v2::FrameFactory::instance(), readAudioProperties, audioPropertiesStyle); - if(ext == "OGG") - return new Ogg::Vorbis::File(fileName, readAudioProperties, audioPropertiesStyle); - if(ext == "OGA") { - /* .oga can be any audio in the Ogg container. First try FLAC, then Vorbis. */ - File *file_flac = new Ogg::FLAC::File(fileName, readAudioProperties, audioPropertiesStyle); - if (file_flac->isValid()) - return file_flac; - delete file_flac; - return new Ogg::Vorbis::File(fileName, readAudioProperties, audioPropertiesStyle); - } - if(ext == "FLAC") - return new FLAC::File(fileName, ID3v2::FrameFactory::instance(), readAudioProperties, audioPropertiesStyle); - if(ext == "MPC") - return new MPC::File(fileName, readAudioProperties, audioPropertiesStyle); - if(ext == "WV") - return new WavPack::File(fileName, readAudioProperties, audioPropertiesStyle); - if(ext == "SPX") - return new Ogg::Speex::File(fileName, readAudioProperties, audioPropertiesStyle); - if(ext == "OPUS") - return new Ogg::Opus::File(fileName, readAudioProperties, audioPropertiesStyle); - if(ext == "TTA") - return new TrueAudio::File(fileName, readAudioProperties, audioPropertiesStyle); - if(ext == "M4A" || ext == "M4R" || ext == "M4B" || ext == "M4P" || ext == "MP4" || ext == "3G2" || ext == "M4V") - return new MP4::File(fileName, readAudioProperties, audioPropertiesStyle); - if(ext == "WMA" || ext == "ASF") - return new ASF::File(fileName, readAudioProperties, audioPropertiesStyle); - if(ext == "AIF" || ext == "AIFF" || ext == "AFC" || ext == "AIFC") - return new RIFF::AIFF::File(fileName, readAudioProperties, audioPropertiesStyle); - if(ext == "WAV") - return new RIFF::WAV::File(fileName, readAudioProperties, audioPropertiesStyle); - if(ext == "APE") - return new APE::File(fileName, readAudioProperties, audioPropertiesStyle); - // module, nst and wow are possible but uncommon extensions - if(ext == "MOD" || ext == "MODULE" || ext == "NST" || ext == "WOW") - return new Mod::File(fileName, readAudioProperties, audioPropertiesStyle); - if(ext == "S3M") - return new S3M::File(fileName, readAudioProperties, audioPropertiesStyle); - if(ext == "IT") - return new IT::File(fileName, readAudioProperties, audioPropertiesStyle); - if(ext == "XM") - return new XM::File(fileName, readAudioProperties, audioPropertiesStyle); - if(ext == "DFF" || ext == "DSDIFF") - return new DSDIFF::File(fileName, readAudioProperties, audioPropertiesStyle); - if(ext == "DSF") - return new DSF::File(fileName, readAudioProperties, audioPropertiesStyle); - - return nullptr; } + + return nullptr; } -class FileRef::FileRefPrivate : public RefCounter -{ -public: - FileRefPrivate() : - RefCounter(), - file(0), - stream(0) {} +// Detect the file type based on the file extension. + +File *detectByExtension(IOStream *stream, bool readAudioProperties, + AudioProperties::ReadStyle audioPropertiesStyle) { +#ifdef _WIN32 + const String s = stream->name().toString(); +#else + const String s(stream->name()); +#endif + + String ext; + const int pos = s.rfind("."); + if (pos != -1) + ext = s.substr(pos + 1).upper(); + + // If this list is updated, the method defaultFileExtensions() should also be + // updated. However at some point that list should be created at the same time + // that a default file type resolver is created. + + if (ext.isEmpty()) + return nullptr; + + // .oga can be any audio in the Ogg container. So leave it to content-based detection. + + if (ext == "MP3") + return new MPEG::File(stream, ID3v2::FrameFactory::instance(), readAudioProperties, audioPropertiesStyle); + if (ext == "OGG") + return new Ogg::Vorbis::File(stream, readAudioProperties, audioPropertiesStyle); + if (ext == "FLAC") + return new FLAC::File(stream, ID3v2::FrameFactory::instance(), readAudioProperties, audioPropertiesStyle); + if (ext == "MPC") + return new MPC::File(stream, readAudioProperties, audioPropertiesStyle); + if (ext == "WV") + return new WavPack::File(stream, readAudioProperties, audioPropertiesStyle); + if (ext == "SPX") + return new Ogg::Speex::File(stream, readAudioProperties, audioPropertiesStyle); + if (ext == "OPUS") + return new Ogg::Opus::File(stream, readAudioProperties, audioPropertiesStyle); + if (ext == "TTA") + return new TrueAudio::File(stream, readAudioProperties, audioPropertiesStyle); + if (ext == "M4A" || ext == "M4R" || ext == "M4B" || ext == "M4P" || ext == "MP4" || ext == "3G2" || ext == "M4V") + return new MP4::File(stream, readAudioProperties, audioPropertiesStyle); + if (ext == "WMA" || ext == "ASF") + return new ASF::File(stream, readAudioProperties, audioPropertiesStyle); + if (ext == "AIF" || ext == "AIFF" || ext == "AFC" || ext == "AIFC") + return new RIFF::AIFF::File(stream, readAudioProperties, audioPropertiesStyle); + if (ext == "WAV") + return new RIFF::WAV::File(stream, readAudioProperties, audioPropertiesStyle); + if (ext == "APE") + return new APE::File(stream, readAudioProperties, audioPropertiesStyle); + // module, nst and wow are possible but uncommon extensions + if (ext == "MOD" || ext == "MODULE" || ext == "NST" || ext == "WOW") + return new Mod::File(stream, readAudioProperties, audioPropertiesStyle); + if (ext == "S3M") + return new S3M::File(stream, readAudioProperties, audioPropertiesStyle); + if (ext == "IT") + return new IT::File(stream, readAudioProperties, audioPropertiesStyle); + if (ext == "XM") + return new XM::File(stream, readAudioProperties, audioPropertiesStyle); + if (ext == "DFF" || ext == "DSDIFF") + return new DSDIFF::File(stream, readAudioProperties, audioPropertiesStyle); + if (ext == "DSF") + return new DSF::File(stream, readAudioProperties, audioPropertiesStyle); + + return nullptr; +} + +// Detect the file type based on the actual content of the stream. + +File *detectByContent(IOStream *stream, bool readAudioProperties, + AudioProperties::ReadStyle audioPropertiesStyle) { + File *file = 0; + + if (MPEG::File::isSupported(stream)) + file = new MPEG::File(stream, ID3v2::FrameFactory::instance(), readAudioProperties, audioPropertiesStyle); + else if (Ogg::Vorbis::File::isSupported(stream)) + file = new Ogg::Vorbis::File(stream, readAudioProperties, audioPropertiesStyle); + else if (Ogg::FLAC::File::isSupported(stream)) + file = new Ogg::FLAC::File(stream, readAudioProperties, audioPropertiesStyle); + else if (FLAC::File::isSupported(stream)) + file = new FLAC::File(stream, ID3v2::FrameFactory::instance(), readAudioProperties, audioPropertiesStyle); + else if (MPC::File::isSupported(stream)) + file = new MPC::File(stream, readAudioProperties, audioPropertiesStyle); + else if (WavPack::File::isSupported(stream)) + file = new WavPack::File(stream, readAudioProperties, audioPropertiesStyle); + else if (Ogg::Speex::File::isSupported(stream)) + file = new Ogg::Speex::File(stream, readAudioProperties, audioPropertiesStyle); + else if (Ogg::Opus::File::isSupported(stream)) + file = new Ogg::Opus::File(stream, readAudioProperties, audioPropertiesStyle); + else if (TrueAudio::File::isSupported(stream)) + file = new TrueAudio::File(stream, readAudioProperties, audioPropertiesStyle); + else if (MP4::File::isSupported(stream)) + file = new MP4::File(stream, readAudioProperties, audioPropertiesStyle); + else if (ASF::File::isSupported(stream)) + file = new ASF::File(stream, readAudioProperties, audioPropertiesStyle); + else if (RIFF::AIFF::File::isSupported(stream)) + file = new RIFF::AIFF::File(stream, readAudioProperties, audioPropertiesStyle); + else if (RIFF::WAV::File::isSupported(stream)) + file = new RIFF::WAV::File(stream, readAudioProperties, audioPropertiesStyle); + else if (APE::File::isSupported(stream)) + file = new APE::File(stream, readAudioProperties, audioPropertiesStyle); + else if (DSDIFF::File::isSupported(stream)) + file = new DSDIFF::File(stream, readAudioProperties, audioPropertiesStyle); + else if (DSF::File::isSupported(stream)) + file = new DSF::File(stream, readAudioProperties, audioPropertiesStyle); + + // isSupported() only does a quick check, so double check the file here. + + if (file) { + if (file->isValid()) + return file; + else + delete file; + } + + return nullptr; +} + +// Internal function that supports FileRef::create(). +// This looks redundant, but necessary in order not to change the previous +// behavior of FileRef::create(). + +File *createInternal(FileName fileName, bool readAudioProperties, + AudioProperties::ReadStyle audioPropertiesStyle) { + File *file = detectByResolvers(fileName, readAudioProperties, audioPropertiesStyle); + if (file) + return file; + +#ifdef _WIN32 + const String s = fileName.toString(); +#else + const String s(fileName); +#endif + + String ext; + const int pos = s.rfind("."); + if (pos != -1) + ext = s.substr(pos + 1).upper(); + + if (ext.isEmpty()) + return nullptr; + + if (ext == "MP3") + return new MPEG::File(fileName, ID3v2::FrameFactory::instance(), readAudioProperties, audioPropertiesStyle); + if (ext == "OGG") + return new Ogg::Vorbis::File(fileName, readAudioProperties, audioPropertiesStyle); + if (ext == "OGA") { + /* .oga can be any audio in the Ogg container. First try FLAC, then Vorbis. */ + File *file_flac = new Ogg::FLAC::File(fileName, readAudioProperties, audioPropertiesStyle); + if (file_flac->isValid()) + return file_flac; + delete file_flac; + return new Ogg::Vorbis::File(fileName, readAudioProperties, audioPropertiesStyle); + } + if (ext == "FLAC") + return new FLAC::File(fileName, ID3v2::FrameFactory::instance(), readAudioProperties, audioPropertiesStyle); + if (ext == "MPC") + return new MPC::File(fileName, readAudioProperties, audioPropertiesStyle); + if (ext == "WV") + return new WavPack::File(fileName, readAudioProperties, audioPropertiesStyle); + if (ext == "SPX") + return new Ogg::Speex::File(fileName, readAudioProperties, audioPropertiesStyle); + if (ext == "OPUS") + return new Ogg::Opus::File(fileName, readAudioProperties, audioPropertiesStyle); + if (ext == "TTA") + return new TrueAudio::File(fileName, readAudioProperties, audioPropertiesStyle); + if (ext == "M4A" || ext == "M4R" || ext == "M4B" || ext == "M4P" || ext == "MP4" || ext == "3G2" || ext == "M4V") + return new MP4::File(fileName, readAudioProperties, audioPropertiesStyle); + if (ext == "WMA" || ext == "ASF") + return new ASF::File(fileName, readAudioProperties, audioPropertiesStyle); + if (ext == "AIF" || ext == "AIFF" || ext == "AFC" || ext == "AIFC") + return new RIFF::AIFF::File(fileName, readAudioProperties, audioPropertiesStyle); + if (ext == "WAV") + return new RIFF::WAV::File(fileName, readAudioProperties, audioPropertiesStyle); + if (ext == "APE") + return new APE::File(fileName, readAudioProperties, audioPropertiesStyle); + // module, nst and wow are possible but uncommon extensions + if (ext == "MOD" || ext == "MODULE" || ext == "NST" || ext == "WOW") + return new Mod::File(fileName, readAudioProperties, audioPropertiesStyle); + if (ext == "S3M") + return new S3M::File(fileName, readAudioProperties, audioPropertiesStyle); + if (ext == "IT") + return new IT::File(fileName, readAudioProperties, audioPropertiesStyle); + if (ext == "XM") + return new XM::File(fileName, readAudioProperties, audioPropertiesStyle); + if (ext == "DFF" || ext == "DSDIFF") + return new DSDIFF::File(fileName, readAudioProperties, audioPropertiesStyle); + if (ext == "DSF") + return new DSF::File(fileName, readAudioProperties, audioPropertiesStyle); + + return nullptr; +} +} // namespace + +class FileRef::FileRefPrivate : public RefCounter { + public: + FileRefPrivate() : RefCounter(), + file(0), + stream(0) {} ~FileRefPrivate() { delete file; delete stream; } - File *file; + File *file; IOStream *stream; }; @@ -295,82 +288,66 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -FileRef::FileRef() : - d(new FileRefPrivate()) -{ +FileRef::FileRef() : d(new FileRefPrivate()) { } FileRef::FileRef(FileName fileName, bool readAudioProperties, - AudioProperties::ReadStyle audioPropertiesStyle) : - d(new FileRefPrivate()) -{ + AudioProperties::ReadStyle audioPropertiesStyle) : d(new FileRefPrivate()) { parse(fileName, readAudioProperties, audioPropertiesStyle); } -FileRef::FileRef(IOStream* stream, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle) : - d(new FileRefPrivate()) -{ +FileRef::FileRef(IOStream *stream, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle) : d(new FileRefPrivate()) { parse(stream, readAudioProperties, audioPropertiesStyle); } -FileRef::FileRef(File *file) : - d(new FileRefPrivate()) -{ +FileRef::FileRef(File *file) : d(new FileRefPrivate()) { d->file = file; } -FileRef::FileRef(const FileRef &ref) : - d(ref.d) -{ +FileRef::FileRef(const FileRef &ref) : d(ref.d) { d->ref(); } -FileRef::~FileRef() -{ - if(d->deref()) +FileRef::~FileRef() { + if (d->deref()) delete d; } -Tag *FileRef::tag() const -{ - if(isNull()) { +Tag *FileRef::tag() const { + if (isNull()) { debug("FileRef::tag() - Called without a valid file."); return nullptr; } return d->file->tag(); } -AudioProperties *FileRef::audioProperties() const -{ - if(isNull()) { +AudioProperties *FileRef::audioProperties() const { + if (isNull()) { debug("FileRef::audioProperties() - Called without a valid file."); return nullptr; } return d->file->audioProperties(); } -File *FileRef::file() const -{ +File *FileRef::file() const { return d->file; } -bool FileRef::save() -{ - if(isNull()) { +bool FileRef::save() { + if (isNull()) { debug("FileRef::save() - Called without a valid file."); return false; } return d->file->save(); } -const FileRef::FileTypeResolver *FileRef::addFileTypeResolver(const FileRef::FileTypeResolver *resolver) // static +const FileRef::FileTypeResolver *FileRef::addFileTypeResolver(const FileRef::FileTypeResolver *resolver) // static { fileTypeResolvers.prepend(resolver); return resolver; } -StringList FileRef::defaultFileExtensions() -{ +StringList FileRef::defaultFileExtensions() { StringList l; l.append("ogg"); @@ -395,49 +372,44 @@ StringList FileRef::defaultFileExtensions() l.append("wav"); l.append("ape"); l.append("mod"); - l.append("module"); // alias for "mod" - l.append("nst"); // alias for "mod" - l.append("wow"); // alias for "mod" + l.append("module"); // alias for "mod" + l.append("nst"); // alias for "mod" + l.append("wow"); // alias for "mod" l.append("s3m"); l.append("it"); l.append("xm"); l.append("dsf"); l.append("dff"); - l.append("dsdiff"); // alias for "dff" + l.append("dsdiff"); // alias for "dff" return l; } -bool FileRef::isNull() const -{ +bool FileRef::isNull() const { return (!d->file || !d->file->isValid()); } -FileRef &FileRef::operator=(const FileRef &ref) -{ +FileRef &FileRef::operator=(const FileRef &ref) { FileRef(ref).swap(*this); return *this; } -void FileRef::swap(FileRef &ref) -{ +void FileRef::swap(FileRef &ref) { using std::swap; swap(d, ref.d); } -bool FileRef::operator==(const FileRef &ref) const -{ +bool FileRef::operator==(const FileRef &ref) const { return (ref.d->file == d->file); } -bool FileRef::operator!=(const FileRef &ref) const -{ +bool FileRef::operator!=(const FileRef &ref) const { return (ref.d->file != d->file); } File *FileRef::create(FileName fileName, bool readAudioProperties, - AudioProperties::ReadStyle audioPropertiesStyle) // static + AudioProperties::ReadStyle audioPropertiesStyle) // static { return createInternal(fileName, readAudioProperties, audioPropertiesStyle); } @@ -447,25 +419,24 @@ File *FileRef::create(FileName fileName, bool readAudioProperties, //////////////////////////////////////////////////////////////////////////////// void FileRef::parse(FileName fileName, bool readAudioProperties, - AudioProperties::ReadStyle audioPropertiesStyle) -{ + AudioProperties::ReadStyle audioPropertiesStyle) { // Try user-defined resolvers. d->file = detectByResolvers(fileName, readAudioProperties, audioPropertiesStyle); - if(d->file) + if (d->file) return; // Try to resolve file types based on the file extension. d->stream = new FileStream(fileName); d->file = detectByExtension(d->stream, readAudioProperties, audioPropertiesStyle); - if(d->file) + if (d->file) return; // At last, try to resolve file types based on the actual content. d->file = detectByContent(d->stream, readAudioProperties, audioPropertiesStyle); - if(d->file) + if (d->file) return; // Stream have to be closed here if failed to resolve file types. @@ -475,14 +446,13 @@ void FileRef::parse(FileName fileName, bool readAudioProperties, } void FileRef::parse(IOStream *stream, bool readAudioProperties, - AudioProperties::ReadStyle audioPropertiesStyle) -{ + AudioProperties::ReadStyle audioPropertiesStyle) { // User-defined resolvers won't work with a stream. // Try to resolve file types based on the file extension. d->file = detectByExtension(stream, readAudioProperties, audioPropertiesStyle); - if(d->file) + if (d->file) return; // At last, try to resolve file types based on the actual content of the file. diff --git a/3rdparty/taglib/fileref.h b/3rdparty/taglib/fileref.h index c66f9d062..d18aaef2b 100644 --- a/3rdparty/taglib/fileref.h +++ b/3rdparty/taglib/fileref.h @@ -35,11 +35,11 @@ namespace Strawberry_TagLib { namespace TagLib { - class Tag; +class Tag; - //! This class provides a simple abstraction for creating and handling files +//! This class provides a simple abstraction for creating and handling files - /*! +/*! * FileRef exists to provide a minimal, generic and value-based wrapper around * a File. It is lightweight and implicitly shared, and as such suitable for * pass-by-value use. This hides some of the uglier details of TagLib::File @@ -57,10 +57,8 @@ namespace TagLib { * \see addFileTypeResolver() */ - class TAGLIB_EXPORT FileRef - { - public: - +class TAGLIB_EXPORT FileRef { + public: //! A class for pluggable file type resolution. /*! @@ -90,11 +88,10 @@ namespace TagLib { * to TagLib. */ - class TAGLIB_EXPORT FileTypeResolver - { - public: - virtual ~FileTypeResolver(); - /*! + class TAGLIB_EXPORT FileTypeResolver { + public: + virtual ~FileTypeResolver(); + /*! * This method must be overridden to provide an additional file type * resolver. If the resolver is able to determine the file type it should * return a valid File object; if not it should return 0. @@ -103,18 +100,18 @@ namespace TagLib { * deleted. Deletion will happen automatically when the FileRef passes * out of scope. */ - virtual File *createFile(FileName fileName, - bool readAudioProperties = true, - AudioProperties::ReadStyle - audioPropertiesStyle = AudioProperties::Average) const = 0; - }; + virtual File *createFile(FileName fileName, + bool readAudioProperties = true, + AudioProperties::ReadStyle + audioPropertiesStyle = AudioProperties::Average) const = 0; + }; - /*! + /*! * Creates a null FileRef. */ - FileRef(); + FileRef(); - /*! + /*! * Create a FileRef from \a fileName. If \a readAudioProperties is true then * the audio properties will be read using \a audioPropertiesStyle. If * \a readAudioProperties is false then \a audioPropertiesStyle will be @@ -123,12 +120,12 @@ namespace TagLib { * Also see the note in the class documentation about why you may not want to * use this method in your application. */ - explicit FileRef(FileName fileName, - bool readAudioProperties = true, - AudioProperties::ReadStyle - audioPropertiesStyle = AudioProperties::Average); + explicit FileRef(FileName fileName, + bool readAudioProperties = true, + AudioProperties::ReadStyle + audioPropertiesStyle = AudioProperties::Average); - /*! + /*! * Construct a FileRef from an opened \a IOStream. If \a readAudioProperties * is true then the audio properties will be read using \a audioPropertiesStyle. * If \a readAudioProperties is false then \a audioPropertiesStyle will be @@ -140,28 +137,28 @@ namespace TagLib { * \note TagLib will *not* take ownership of the stream, the caller is * responsible for deleting it after the File object. */ - explicit FileRef(IOStream* stream, - bool readAudioProperties = true, - AudioProperties::ReadStyle - audioPropertiesStyle = AudioProperties::Average); + explicit FileRef(IOStream *stream, + bool readAudioProperties = true, + AudioProperties::ReadStyle + audioPropertiesStyle = AudioProperties::Average); - /*! + /*! * Construct a FileRef using \a file. The FileRef now takes ownership of the * pointer and will delete the File when it passes out of scope. */ - explicit FileRef(File *file); + explicit FileRef(File *file); - /*! + /*! * Make a copy of \a ref. */ - FileRef(const FileRef &ref); + FileRef(const FileRef &ref); - /*! + /*! * Destroys this FileRef instance. */ - virtual ~FileRef(); + virtual ~FileRef(); - /*! + /*! * Returns a pointer to represented file's tag. * * \warning This pointer will become invalid when this FileRef and all @@ -172,15 +169,15 @@ namespace TagLib { * * \see File::tag() */ - Tag *tag() const; + Tag *tag() const; - /*! + /*! * Returns the audio properties for this FileRef. If no audio properties * were read then this will returns a null pointer. */ - AudioProperties *audioProperties() const; + AudioProperties *audioProperties() const; - /*! + /*! * Returns a pointer to the file represented by this handler class. * * As a general rule this call should be avoided since if you need to work @@ -195,14 +192,14 @@ namespace TagLib { * \warning This pointer will become invalid when this FileRef and all * copies pass out of scope. */ - File *file() const; + File *file() const; - /*! + /*! * Saves the file. Returns true on success. */ - bool save(); + bool save(); - /*! + /*! * Adds a FileTypeResolver to the list of those used by TagLib. Each * additional FileTypeResolver is added to the front of a list of resolvers * that are tried. If the FileTypeResolver returns zero the next resolver @@ -214,9 +211,9 @@ namespace TagLib { * * \see FileTypeResolver */ - static const FileTypeResolver *addFileTypeResolver(const FileTypeResolver *resolver); + static const FileTypeResolver *addFileTypeResolver(const FileTypeResolver *resolver); - /*! + /*! * As is mentioned elsewhere in this class's documentation, the default file * type resolution code provided by TagLib only works by comparing file * extensions. @@ -232,35 +229,35 @@ namespace TagLib { * * \see FileTypeResolver */ - static StringList defaultFileExtensions(); + static StringList defaultFileExtensions(); - /*! + /*! * Returns true if the file (and as such other pointers) are null. */ - bool isNull() const; + bool isNull() const; - /*! + /*! * Assign the file pointed to by \a ref to this FileRef. */ - FileRef &operator=(const FileRef &ref); + FileRef &operator=(const FileRef &ref); - /*! + /*! * Exchanges the content of the FileRef by the content of \a ref. */ - void swap(FileRef &ref); + void swap(FileRef &ref); - /*! + /*! * Returns true if this FileRef and \a ref point to the same File object. */ - bool operator==(const FileRef &ref) const; + bool operator==(const FileRef &ref) const; - /*! + /*! * Returns true if this FileRef and \a ref do not point to the same File * object. */ - bool operator!=(const FileRef &ref) const; + bool operator!=(const FileRef &ref) const; - /*! + /*! * A simple implementation of file type guessing. If \a readAudioProperties * is true then the audio properties will be read using * \a audioPropertiesStyle. If \a readAudioProperties is false then @@ -271,19 +268,19 @@ namespace TagLib { * * \deprecated */ - static File *create(FileName fileName, - bool readAudioProperties = true, - AudioProperties::ReadStyle audioPropertiesStyle = AudioProperties::Average); + static File *create(FileName fileName, + bool readAudioProperties = true, + AudioProperties::ReadStyle audioPropertiesStyle = AudioProperties::Average); - private: - void parse(FileName fileName, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle); - void parse(IOStream *stream, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle); + private: + void parse(FileName fileName, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle); + void parse(IOStream *stream, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle); - class FileRefPrivate; - FileRefPrivate *d; - }; + class FileRefPrivate; + FileRefPrivate *d; +}; -} -} // namespace Strawberry_TagLib::TagLib +} // namespace TagLib +} // namespace Strawberry_TagLib #endif // TAGLIB_FILEREF_H diff --git a/3rdparty/taglib/flac/flacfile.cpp b/3rdparty/taglib/flac/flacfile.cpp index d248d49ba..328cd758a 100644 --- a/3rdparty/taglib/flac/flacfile.cpp +++ b/3rdparty/taglib/flac/flacfile.cpp @@ -43,38 +43,35 @@ using namespace Strawberry_TagLib::TagLib; -namespace -{ - typedef List BlockList; - typedef BlockList::Iterator BlockIterator; - typedef BlockList::Iterator BlockConstIterator; +namespace { +typedef List BlockList; +typedef BlockList::Iterator BlockIterator; +typedef BlockList::Iterator BlockConstIterator; - enum { FlacXiphIndex = 0, FlacID3v2Index = 1, FlacID3v1Index = 2 }; +enum { FlacXiphIndex = 0, + FlacID3v2Index = 1, + FlacID3v1Index = 2 }; - const long MinPaddingLength = 4096; - const long MaxPaddingLegnth = 1024 * 1024; +const long MinPaddingLength = 4096; +const long MaxPaddingLegnth = 1024 * 1024; - const char LastBlockFlag = '\x80'; -} +const char LastBlockFlag = '\x80'; +} // namespace -class FLAC::File::FilePrivate -{ -public: - explicit FilePrivate(const ID3v2::FrameFactory *frameFactory = ID3v2::FrameFactory::instance()) : - ID3v2FrameFactory(frameFactory), - ID3v2Location(-1), - ID3v2OriginalSize(0), - ID3v1Location(-1), - properties(0), - flacStart(0), - streamStart(0), - scanned(false) - { +class FLAC::File::FilePrivate { + public: + explicit FilePrivate(const ID3v2::FrameFactory *frameFactory = ID3v2::FrameFactory::instance()) : ID3v2FrameFactory(frameFactory), + ID3v2Location(-1), + ID3v2OriginalSize(0), + ID3v1Location(-1), + properties(0), + flacStart(0), + streamStart(0), + scanned(false) { blocks.setAutoDelete(true); } - ~FilePrivate() - { + ~FilePrivate() { delete properties; } @@ -99,8 +96,7 @@ public: // static members //////////////////////////////////////////////////////////////////////////////// -bool FLAC::File::isSupported(IOStream *stream) -{ +bool FLAC::File::isSupported(IOStream *stream) { // A FLAC file has an ID "fLaC" somewhere. An ID3v2 tag may precede. const ByteVector buffer = Utils::readHeader(stream, bufferSize(), true); @@ -111,84 +107,71 @@ bool FLAC::File::isSupported(IOStream *stream) // public members //////////////////////////////////////////////////////////////////////////////// -FLAC::File::File(FileName file, bool readProperties, Properties::ReadStyle) : - Strawberry_TagLib::TagLib::File(file), - d(new FilePrivate()) -{ - if(isOpen()) +FLAC::File::File(FileName file, bool readProperties, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(file), + d(new FilePrivate()) { + if (isOpen()) read(readProperties); } FLAC::File::File(FileName file, ID3v2::FrameFactory *frameFactory, - bool readProperties, Properties::ReadStyle) : - Strawberry_TagLib::TagLib::File(file), - d(new FilePrivate(frameFactory)) -{ - if(isOpen()) + bool readProperties, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(file), + d(new FilePrivate(frameFactory)) { + if (isOpen()) read(readProperties); } FLAC::File::File(IOStream *stream, ID3v2::FrameFactory *frameFactory, - bool readProperties, Properties::ReadStyle) : - Strawberry_TagLib::TagLib::File(stream), - d(new FilePrivate(frameFactory)) -{ - if(isOpen()) + bool readProperties, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(stream), + d(new FilePrivate(frameFactory)) { + if (isOpen()) read(readProperties); } -FLAC::File::~File() -{ +FLAC::File::~File() { delete d; } -Strawberry_TagLib::TagLib::Tag *FLAC::File::tag() const -{ +Strawberry_TagLib::TagLib::Tag *FLAC::File::tag() const { return &d->tag; } -PropertyMap FLAC::File::properties() const -{ +PropertyMap FLAC::File::properties() const { return d->tag.properties(); } -void FLAC::File::removeUnsupportedProperties(const StringList &unsupported) -{ +void FLAC::File::removeUnsupportedProperties(const StringList &unsupported) { d->tag.removeUnsupportedProperties(unsupported); } -PropertyMap FLAC::File::setProperties(const PropertyMap &properties) -{ +PropertyMap FLAC::File::setProperties(const PropertyMap &properties) { return xiphComment(true)->setProperties(properties); } -FLAC::Properties *FLAC::File::audioProperties() const -{ +FLAC::Properties *FLAC::File::audioProperties() const { return d->properties; } -bool FLAC::File::save() -{ - if(readOnly()) { +bool FLAC::File::save() { + if (readOnly()) { debug("FLAC::File::save() - Cannot save to a read only file."); return false; } - if(!isValid()) { + if (!isValid()) { debug("FLAC::File::save() -- Trying to save invalid file."); return false; } // Create new vorbis comments - if(!hasXiphComment()) + if (!hasXiphComment()) Tag::duplicate(&d->tag, xiphComment(true), false); d->xiphCommentData = xiphComment()->render(false); // Replace metadata blocks - for(BlockIterator it = d->blocks.begin(); it != d->blocks.end(); ++it) { - if((*it)->code() == MetadataBlock::VorbisComment) { + for (BlockIterator it = d->blocks.begin(); it != d->blocks.end(); ++it) { + if ((*it)->code() == MetadataBlock::VorbisComment) { // Set the new Vorbis Comment block delete *it; d->blocks.erase(it); @@ -201,7 +184,7 @@ bool FLAC::File::save() // Render data for the metadata blocks ByteVector data; - for(BlockConstIterator it = d->blocks.begin(); it != d->blocks.end(); ++it) { + for (BlockConstIterator it = d->blocks.begin(); it != d->blocks.end(); ++it) { ByteVector blockData = (*it)->render(); ByteVector blockHeader = ByteVector::fromUInt(blockData.size()); blockHeader[0] = (*it)->code(); @@ -214,7 +197,7 @@ bool FLAC::File::save() long originalLength = d->streamStart - d->flacStart; long paddingLength = originalLength - data.size() - 4; - if(paddingLength <= 0) { + if (paddingLength <= 0) { paddingLength = MinPaddingLength; } else { @@ -224,7 +207,7 @@ bool FLAC::File::save() threshold = std::max(threshold, MinPaddingLength); threshold = std::min(threshold, MaxPaddingLegnth); - if(paddingLength > threshold) + if (paddingLength > threshold) paddingLength = MinPaddingLength; } @@ -239,25 +222,25 @@ bool FLAC::File::save() d->streamStart += (static_cast(data.size()) - originalLength); - if(d->ID3v1Location >= 0) + if (d->ID3v1Location >= 0) d->ID3v1Location += (static_cast(data.size()) - originalLength); // Update ID3 tags - if(ID3v2Tag() && !ID3v2Tag()->isEmpty()) { + if (ID3v2Tag() && !ID3v2Tag()->isEmpty()) { // ID3v2 tag is not empty. Update the old one or create a new one. - if(d->ID3v2Location < 0) + if (d->ID3v2Location < 0) d->ID3v2Location = 0; data = ID3v2Tag()->render(); insert(data, d->ID3v2Location, d->ID3v2OriginalSize); - d->flacStart += (static_cast(data.size()) - d->ID3v2OriginalSize); + d->flacStart += (static_cast(data.size()) - d->ID3v2OriginalSize); d->streamStart += (static_cast(data.size()) - d->ID3v2OriginalSize); - if(d->ID3v1Location >= 0) + if (d->ID3v1Location >= 0) d->ID3v1Location += (static_cast(data.size()) - d->ID3v2OriginalSize); d->ID3v2OriginalSize = data.size(); @@ -266,13 +249,13 @@ bool FLAC::File::save() // ID3v2 tag is empty. Remove the old one. - if(d->ID3v2Location >= 0) { + if (d->ID3v2Location >= 0) { removeBlock(d->ID3v2Location, d->ID3v2OriginalSize); - d->flacStart -= d->ID3v2OriginalSize; + d->flacStart -= d->ID3v2OriginalSize; d->streamStart -= d->ID3v2OriginalSize; - if(d->ID3v1Location >= 0) + if (d->ID3v1Location >= 0) d->ID3v1Location -= d->ID3v2OriginalSize; d->ID3v2Location = -1; @@ -280,11 +263,11 @@ bool FLAC::File::save() } } - if(ID3v1Tag() && !ID3v1Tag()->isEmpty()) { + if (ID3v1Tag() && !ID3v1Tag()->isEmpty()) { // ID3v1 tag is not empty. Update the old one or create a new one. - if(d->ID3v1Location >= 0) { + if (d->ID3v1Location >= 0) { seek(d->ID3v1Location); } else { @@ -298,7 +281,7 @@ bool FLAC::File::save() // ID3v1 tag is empty. Remove the old one. - if(d->ID3v1Location >= 0) { + if (d->ID3v1Location >= 0) { truncate(d->ID3v1Location); d->ID3v1Location = -1; } @@ -307,69 +290,59 @@ bool FLAC::File::save() return true; } -ID3v2::Tag *FLAC::File::ID3v2Tag(bool create) -{ +ID3v2::Tag *FLAC::File::ID3v2Tag(bool create) { return d->tag.access(FlacID3v2Index, create); } -ID3v1::Tag *FLAC::File::ID3v1Tag(bool create) -{ +ID3v1::Tag *FLAC::File::ID3v1Tag(bool create) { return d->tag.access(FlacID3v1Index, create); } -Ogg::XiphComment *FLAC::File::xiphComment(bool create) -{ +Ogg::XiphComment *FLAC::File::xiphComment(bool create) { return d->tag.access(FlacXiphIndex, create); } -void FLAC::File::setID3v2FrameFactory(const ID3v2::FrameFactory *factory) -{ +void FLAC::File::setID3v2FrameFactory(const ID3v2::FrameFactory *factory) { d->ID3v2FrameFactory = factory; } -ByteVector FLAC::File::streamInfoData() -{ +ByteVector FLAC::File::streamInfoData() { debug("FLAC::File::streamInfoData() -- This function is obsolete. Returning an empty ByteVector."); return ByteVector(); } -long FLAC::File::streamLength() -{ +long FLAC::File::streamLength() { debug("FLAC::File::streamLength() -- This function is obsolete. Returning zero."); return 0; } -List FLAC::File::pictureList() -{ +List FLAC::File::pictureList() { List pictures; - for(BlockConstIterator it = d->blocks.begin(); it != d->blocks.end(); ++it) { + for (BlockConstIterator it = d->blocks.begin(); it != d->blocks.end(); ++it) { Picture *picture = dynamic_cast(*it); - if(picture) { + if (picture) { pictures.append(picture); } } return pictures; } -void FLAC::File::addPicture(Picture *picture) -{ +void FLAC::File::addPicture(Picture *picture) { d->blocks.append(picture); } -void FLAC::File::removePicture(Picture *picture, bool del) -{ +void FLAC::File::removePicture(Picture *picture, bool del) { BlockIterator it = d->blocks.find(picture); - if(it != d->blocks.end()) + if (it != d->blocks.end()) d->blocks.erase(it); - if(del) + if (del) delete picture; } -void FLAC::File::removePictures() -{ - for(BlockIterator it = d->blocks.begin(); it != d->blocks.end(); ) { - if(dynamic_cast(*it)) { +void FLAC::File::removePictures() { + for (BlockIterator it = d->blocks.begin(); it != d->blocks.end();) { + if (dynamic_cast(*it)) { delete *it; it = d->blocks.erase(it); } @@ -379,32 +352,28 @@ void FLAC::File::removePictures() } } -void FLAC::File::strip(int tags) -{ - if(tags & ID3v1) +void FLAC::File::strip(int tags) { + if (tags & ID3v1) d->tag.set(FlacID3v1Index, 0); - if(tags & ID3v2) + if (tags & ID3v2) d->tag.set(FlacID3v2Index, 0); - if(tags & XiphComment) { + if (tags & XiphComment) { xiphComment()->removeAllFields(); xiphComment()->removeAllPictures(); } } -bool FLAC::File::hasXiphComment() const -{ +bool FLAC::File::hasXiphComment() const { return !d->xiphCommentData.isEmpty(); } -bool FLAC::File::hasID3v1Tag() const -{ +bool FLAC::File::hasID3v1Tag() const { return (d->ID3v1Location >= 0); } -bool FLAC::File::hasID3v2Tag() const -{ +bool FLAC::File::hasID3v2Tag() const { return (d->ID3v2Location >= 0); } @@ -412,13 +381,12 @@ bool FLAC::File::hasID3v2Tag() const // private members //////////////////////////////////////////////////////////////////////////////// -void FLAC::File::read(bool readProperties) -{ +void FLAC::File::read(bool readProperties) { // Look for an ID3v2 tag d->ID3v2Location = Utils::findID3v2(this); - if(d->ID3v2Location >= 0) { + if (d->ID3v2Location >= 0) { d->tag.set(FlacID3v2Index, new ID3v2::Tag(this, d->ID3v2Location, d->ID3v2FrameFactory)); d->ID3v2OriginalSize = ID3v2Tag()->header()->completeTagSize(); } @@ -427,22 +395,22 @@ void FLAC::File::read(bool readProperties) d->ID3v1Location = Utils::findID3v1(this); - if(d->ID3v1Location >= 0) + if (d->ID3v1Location >= 0) d->tag.set(FlacID3v1Index, new ID3v1::Tag(this, d->ID3v1Location)); // Look for FLAC metadata, including vorbis comments scan(); - if(!isValid()) + if (!isValid()) return; - if(!d->xiphCommentData.isEmpty()) + if (!d->xiphCommentData.isEmpty()) d->tag.set(FlacXiphIndex, new Ogg::XiphComment(d->xiphCommentData)); else d->tag.set(FlacXiphIndex, new Ogg::XiphComment()); - if(readProperties) { + if (readProperties) { // First block should be the stream_info metadata @@ -450,7 +418,7 @@ void FLAC::File::read(bool readProperties) long streamLength; - if(d->ID3v1Location >= 0) + if (d->ID3v1Location >= 0) streamLength = d->ID3v1Location - d->streamStart; else streamLength = length() - d->streamStart; @@ -459,24 +427,23 @@ void FLAC::File::read(bool readProperties) } } -void FLAC::File::scan() -{ +void FLAC::File::scan() { // Scan the metadata pages - if(d->scanned) + if (d->scanned) return; - if(!isValid()) + if (!isValid()) return; long nextBlockOffset; - if(d->ID3v2Location >= 0) + if (d->ID3v2Location >= 0) nextBlockOffset = find("fLaC", d->ID3v2Location + d->ID3v2OriginalSize); else nextBlockOffset = find("fLaC"); - if(nextBlockOffset < 0) { + if (nextBlockOffset < 0) { debug("FLAC::File::scan() -- FLAC stream not found"); setValid(false); return; @@ -485,7 +452,7 @@ void FLAC::File::scan() nextBlockOffset += 4; d->flacStart = nextBlockOffset; - while(true) { + while (true) { seek(nextBlockOffset); const ByteVector header = readBlock(4); @@ -508,22 +475,20 @@ void FLAC::File::scan() // First block should be the stream_info metadata - if(d->blocks.isEmpty() && blockType != MetadataBlock::StreamInfo) { + if (d->blocks.isEmpty() && blockType != MetadataBlock::StreamInfo) { debug("FLAC::File::scan() -- First block should be the stream_info metadata"); setValid(false); return; } - if(blockLength == 0 - && blockType != MetadataBlock::Padding && blockType != MetadataBlock::SeekTable) - { + if (blockLength == 0 && blockType != MetadataBlock::Padding && blockType != MetadataBlock::SeekTable) { debug("FLAC::File::scan() -- Zero-sized metadata block found"); setValid(false); return; } const ByteVector data = readBlock(blockLength); - if(data.size() != blockLength) { + if (data.size() != blockLength) { debug("FLAC::File::scan() -- Failed to read a metadata block"); setValid(false); return; @@ -532,8 +497,8 @@ void FLAC::File::scan() MetadataBlock *block = 0; // Found the vorbis-comment - if(blockType == MetadataBlock::VorbisComment) { - if(d->xiphCommentData.isEmpty()) { + if (blockType == MetadataBlock::VorbisComment) { + if (d->xiphCommentData.isEmpty()) { d->xiphCommentData = data; block = new UnknownMetadataBlock(MetadataBlock::VorbisComment, data); } @@ -541,9 +506,9 @@ void FLAC::File::scan() debug("FLAC::File::scan() -- multiple Vorbis Comment blocks found, discarding"); } } - else if(blockType == MetadataBlock::Picture) { + else if (blockType == MetadataBlock::Picture) { FLAC::Picture *picture = new FLAC::Picture(); - if(picture->parse(data)) { + if (picture->parse(data)) { block = picture; } else { @@ -551,19 +516,19 @@ void FLAC::File::scan() delete picture; } } - else if(blockType == MetadataBlock::Padding) { + else if (blockType == MetadataBlock::Padding) { // Skip all padding blocks. } else { block = new UnknownMetadataBlock(blockType, data); } - if(block) + if (block) d->blocks.append(block); nextBlockOffset += blockLength + 4; - if(isLastBlock) + if (isLastBlock) break; } diff --git a/3rdparty/taglib/flac/flacfile.h b/3rdparty/taglib/flac/flacfile.h index 164aff555..a870f44da 100644 --- a/3rdparty/taglib/flac/flacfile.h +++ b/3rdparty/taglib/flac/flacfile.h @@ -37,14 +37,21 @@ namespace Strawberry_TagLib { namespace TagLib { - class Tag; - namespace ID3v2 { class FrameFactory; class Tag; } - namespace ID3v1 { class Tag; } - namespace Ogg { class XiphComment; } +class Tag; +namespace ID3v2 { +class FrameFactory; +class Tag; +} // namespace ID3v2 +namespace ID3v1 { +class Tag; +} +namespace Ogg { +class XiphComment; +} - //! An implementation of FLAC metadata +//! An implementation of FLAC metadata - /*! +/*! * This is implementation of FLAC metadata for non-Ogg FLAC files. At some * point when Ogg / FLAC is more common there will be a similar implementation * under the Ogg hierarchy. @@ -53,38 +60,37 @@ namespace TagLib { * properties from the file. */ - namespace FLAC { +namespace FLAC { - //! An implementation of TagLib::File with FLAC specific methods +//! An implementation of TagLib::File with FLAC specific methods - /*! +/*! * This implements and provides an interface for FLAC files to the * TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing * the abstract TagLib::File API as well as providing some additional * information specific to FLAC files. */ - class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File - { - public: - /*! +class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File { + public: + /*! * This set of flags is used for various operations and is suitable for * being OR-ed together. */ - enum TagTypes { - //! Empty set. Matches no tag types. - NoTags = 0x0000, - //! Matches Vorbis comments. - XiphComment = 0x0001, - //! Matches ID3v1 tags. - ID3v1 = 0x0002, - //! Matches ID3v2 tags. - ID3v2 = 0x0004, - //! Matches all tag types. - AllTags = 0xffff - }; + enum TagTypes { + //! Empty set. Matches no tag types. + NoTags = 0x0000, + //! Matches Vorbis comments. + XiphComment = 0x0001, + //! Matches ID3v1 tags. + ID3v1 = 0x0002, + //! Matches ID3v2 tags. + ID3v2 = 0x0004, + //! Matches all tag types. + AllTags = 0xffff + }; - /*! + /*! * Constructs a FLAC file from \a file. If \a readProperties is true the * file's audio properties will also be read. * @@ -93,10 +99,10 @@ namespace TagLib { * \deprecated This constructor will be dropped in favor of the one below * in a future version. */ - File(FileName file, bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(FileName file, bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Constructs an FLAC file from \a file. If \a readProperties is true the * file's audio properties will also be read. * @@ -105,12 +111,12 @@ namespace TagLib { * * \note In the current implementation, \a propertiesStyle is ignored. */ - // BIC: merge with the above constructor - File(FileName file, ID3v2::FrameFactory *frameFactory, - bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + // BIC: merge with the above constructor + File(FileName file, ID3v2::FrameFactory *frameFactory, + bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Constructs a FLAC file from \a stream. If \a readProperties is true the * file's audio properties will also be read. * @@ -122,17 +128,17 @@ namespace TagLib { * * \note In the current implementation, \a propertiesStyle is ignored. */ - // BIC: merge with the above constructor - File(IOStream *stream, ID3v2::FrameFactory *frameFactory, - bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + // BIC: merge with the above constructor + File(IOStream *stream, ID3v2::FrameFactory *frameFactory, + bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Destroys this instance of the File. */ - virtual ~File(); + virtual ~File(); - /*! + /*! * Returns the Tag for this file. This will be a union of XiphComment, * ID3v1 and ID3v2 tags. * @@ -140,43 +146,43 @@ namespace TagLib { * \see ID3v1Tag() * \see XiphComment() */ - virtual Strawberry_TagLib::TagLib::Tag *tag() const; + virtual Strawberry_TagLib::TagLib::Tag *tag() const; - /*! + /*! * Implements the unified property interface -- export function. * If the file contains more than one tag (e.g. XiphComment and ID3v1), * only the first one (in the order XiphComment, ID3v2, ID3v1) will be * converted to the PropertyMap. */ - PropertyMap properties() const; + PropertyMap properties() const; - void removeUnsupportedProperties(const StringList &); + void removeUnsupportedProperties(const StringList &); - /*! + /*! * Implements the unified property interface -- import function. * This always creates a Xiph comment, if none exists. The return value * relates to the Xiph comment only. * Ignores any changes to ID3v1 or ID3v2 comments since they are not allowed * in the FLAC specification. */ - PropertyMap setProperties(const PropertyMap &); + PropertyMap setProperties(const PropertyMap &); - /*! + /*! * Returns the FLAC::Properties for this file. If no audio properties * were read then this will return a null pointer. */ - virtual Properties *audioProperties() const; + virtual Properties *audioProperties() const; - /*! + /*! * Save the file. This will primarily save the XiphComment, but * will also keep any old ID3-tags up to date. If the file * has no XiphComment, one will be constructed from the ID3-tags. * * This returns true if the save was successful. */ - virtual bool save(); + virtual bool save(); - /*! + /*! * Returns a pointer to the ID3v2 tag of the file. * * If \a create is false (the default) this returns a null pointer @@ -193,9 +199,9 @@ namespace TagLib { * * \see hasID3v2Tag() */ - ID3v2::Tag *ID3v2Tag(bool create = false); + ID3v2::Tag *ID3v2Tag(bool create = false); - /*! + /*! * Returns a pointer to the ID3v1 tag of the file. * * If \a create is false (the default) this returns a null pointer @@ -212,9 +218,9 @@ namespace TagLib { * * \see hasID3v1Tag() */ - ID3v1::Tag *ID3v1Tag(bool create = false); + ID3v1::Tag *ID3v1Tag(bool create = false); - /*! + /*! * Returns a pointer to the XiphComment for the file. * * If \a create is false (the default) this returns a null pointer @@ -231,9 +237,9 @@ namespace TagLib { * * \see hasXiphComment() */ - Ogg::XiphComment *xiphComment(bool create = false); + Ogg::XiphComment *xiphComment(bool create = false); - /*! + /*! * Set the ID3v2::FrameFactory to something other than the default. This * can be used to specify the way that ID3v2 frames will be interpreted * when @@ -241,49 +247,49 @@ namespace TagLib { * \see ID3v2FrameFactory * \deprecated This value should be passed in via the constructor */ - TAGLIB_DEPRECATED void setID3v2FrameFactory(const ID3v2::FrameFactory *factory); + TAGLIB_DEPRECATED void setID3v2FrameFactory(const ID3v2::FrameFactory *factory); - /*! + /*! * Returns the block of data used by FLAC::Properties for parsing the * stream properties. * * \deprecated Always returns an empty vector. */ - TAGLIB_DEPRECATED ByteVector streamInfoData(); // BIC: remove + TAGLIB_DEPRECATED ByteVector streamInfoData(); // BIC: remove - /*! + /*! * Returns the length of the audio-stream, used by FLAC::Properties for * calculating the bitrate. * * \deprecated Always returns zero. */ - TAGLIB_DEPRECATED long streamLength(); // BIC: remove + TAGLIB_DEPRECATED long streamLength(); // BIC: remove - /*! + /*! * Returns a list of pictures attached to the FLAC file. */ - List pictureList(); + List pictureList(); - /*! + /*! * Removes an attached picture. If \a del is true the picture's memory * will be freed; if it is false, it must be deleted by the user. */ - void removePicture(Picture *picture, bool del = true); + void removePicture(Picture *picture, bool del = true); - /*! + /*! * Remove all attached images. */ - void removePictures(); + void removePictures(); - /*! + /*! * Add a new picture to the file. The file takes ownership of the * picture and will handle freeing its memory. * * \note The file will be saved only after calling save(). */ - void addPicture(Picture *picture); + void addPicture(Picture *picture); - /*! + /*! * This will remove the tags that match the OR-ed together TagTypes from * the file. By default it removes all tags. * @@ -296,50 +302,50 @@ namespace TagLib { * \note This won't remove the Vorbis comment block completely. The * vendor ID will be preserved. */ - void strip(int tags = AllTags); + void strip(int tags = AllTags); - /*! + /*! * Returns whether or not the file on disk actually has a XiphComment. * * \see xiphComment() */ - bool hasXiphComment() const; + bool hasXiphComment() const; - /*! + /*! * Returns whether or not the file on disk actually has an ID3v1 tag. * * \see ID3v1Tag() */ - bool hasID3v1Tag() const; + bool hasID3v1Tag() const; - /*! + /*! * Returns whether or not the file on disk actually has an ID3v2 tag. * * \see ID3v2Tag() */ - bool hasID3v2Tag() const; + bool hasID3v2Tag() const; - /*! + /*! * Returns whether or not the given \a stream can be opened as a FLAC * file. * * \note This method is designed to do a quick check. The result may * not necessarily be correct. */ - static bool isSupported(IOStream *stream); + static bool isSupported(IOStream *stream); - private: - File(const File &); - File &operator=(const File &); + private: + File(const File &); + File &operator=(const File &); - void read(bool readProperties); - void scan(); + void read(bool readProperties); + void scan(); - class FilePrivate; - FilePrivate *d; - }; - } -} -} + class FilePrivate; + FilePrivate *d; +}; +} // namespace FLAC +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/flac/flacmetadatablock.cpp b/3rdparty/taglib/flac/flacmetadatablock.cpp index aa02ebf6c..70b6cedd3 100644 --- a/3rdparty/taglib/flac/flacmetadatablock.cpp +++ b/3rdparty/taglib/flac/flacmetadatablock.cpp @@ -29,19 +29,14 @@ using namespace Strawberry_TagLib::TagLib; -class FLAC::MetadataBlock::MetadataBlockPrivate -{ -public: +class FLAC::MetadataBlock::MetadataBlockPrivate { + public: MetadataBlockPrivate() {} - }; -FLAC::MetadataBlock::MetadataBlock() -{ +FLAC::MetadataBlock::MetadataBlock() { d = 0; } -FLAC::MetadataBlock::~MetadataBlock() -{ +FLAC::MetadataBlock::~MetadataBlock() { } - diff --git a/3rdparty/taglib/flac/flacmetadatablock.h b/3rdparty/taglib/flac/flacmetadatablock.h index c264ad54f..da5f5ce49 100644 --- a/3rdparty/taglib/flac/flacmetadatablock.h +++ b/3rdparty/taglib/flac/flacmetadatablock.h @@ -33,45 +33,44 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace FLAC { +namespace FLAC { - class TAGLIB_EXPORT MetadataBlock - { - public: - MetadataBlock(); - virtual ~MetadataBlock(); +class TAGLIB_EXPORT MetadataBlock { + public: + MetadataBlock(); + virtual ~MetadataBlock(); - enum BlockType { - StreamInfo = 0, - Padding, - Application, - SeekTable, - VorbisComment, - CueSheet, - Picture - }; + enum BlockType { + StreamInfo = 0, + Padding, + Application, + SeekTable, + VorbisComment, + CueSheet, + Picture + }; - /*! + /*! * Returns the FLAC metadata block type. */ - virtual int code() const = 0; + virtual int code() const = 0; - /*! + /*! * Render the content of the block. */ - virtual ByteVector render() const = 0; + virtual ByteVector render() const = 0; - private: - MetadataBlock(const MetadataBlock &item); - MetadataBlock &operator=(const MetadataBlock &item); + private: + MetadataBlock(const MetadataBlock &item); + MetadataBlock &operator=(const MetadataBlock &item); - class MetadataBlockPrivate; - MetadataBlockPrivate *d; - }; + class MetadataBlockPrivate; + MetadataBlockPrivate *d; +}; - } +} // namespace FLAC -} -} +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/flac/flacpicture.cpp b/3rdparty/taglib/flac/flacpicture.cpp index 1ca86e3a7..1ef8e42ab 100644 --- a/3rdparty/taglib/flac/flacpicture.cpp +++ b/3rdparty/taglib/flac/flacpicture.cpp @@ -29,16 +29,14 @@ using namespace Strawberry_TagLib::TagLib; -class FLAC::Picture::PicturePrivate -{ -public: - PicturePrivate() : - type(FLAC::Picture::Other), - width(0), - height(0), - colorDepth(0), - numColors(0) - {} +class FLAC::Picture::PicturePrivate { + public: + PicturePrivate() : type(FLAC::Picture::Other), + width(0), + height(0), + colorDepth(0), + numColors(0) { + } Type type; String mimeType; @@ -50,30 +48,23 @@ public: ByteVector data; }; -FLAC::Picture::Picture() : - d(new PicturePrivate()) -{ +FLAC::Picture::Picture() : d(new PicturePrivate()) { } -FLAC::Picture::Picture(const ByteVector &data) : - d(new PicturePrivate()) -{ +FLAC::Picture::Picture(const ByteVector &data) : d(new PicturePrivate()) { parse(data); } -FLAC::Picture::~Picture() -{ +FLAC::Picture::~Picture() { delete d; } -int FLAC::Picture::code() const -{ +int FLAC::Picture::code() const { return FLAC::MetadataBlock::Picture; } -bool FLAC::Picture::parse(const ByteVector &data) -{ - if(data.size() < 32) { +bool FLAC::Picture::parse(const ByteVector &data) { + if (data.size() < 32) { debug("A picture block must contain at least 5 bytes."); return false; } @@ -83,7 +74,7 @@ bool FLAC::Picture::parse(const ByteVector &data) pos += 4; unsigned int mimeTypeLength = data.toUInt(pos); pos += 4; - if(pos + mimeTypeLength + 24 > data.size()) { + if (pos + mimeTypeLength + 24 > data.size()) { debug("Invalid picture block."); return false; } @@ -91,7 +82,7 @@ bool FLAC::Picture::parse(const ByteVector &data) pos += mimeTypeLength; unsigned int descriptionLength = data.toUInt(pos); pos += 4; - if(pos + descriptionLength + 20 > data.size()) { + if (pos + descriptionLength + 20 > data.size()) { debug("Invalid picture block."); return false; } @@ -107,7 +98,7 @@ bool FLAC::Picture::parse(const ByteVector &data) pos += 4; unsigned int dataLength = data.toUInt(pos); pos += 4; - if(pos + dataLength > data.size()) { + if (pos + dataLength > data.size()) { debug("Invalid picture block."); return false; } @@ -116,8 +107,7 @@ bool FLAC::Picture::parse(const ByteVector &data) return true; } -ByteVector FLAC::Picture::render() const -{ +ByteVector FLAC::Picture::render() const { ByteVector result; result.append(ByteVector::fromUInt(d->type)); ByteVector mimeTypeData = d->mimeType.data(String::UTF8); @@ -135,83 +125,66 @@ ByteVector FLAC::Picture::render() const return result; } -FLAC::Picture::Type FLAC::Picture::type() const -{ +FLAC::Picture::Type FLAC::Picture::type() const { return d->type; } -void FLAC::Picture::setType(FLAC::Picture::Type type) -{ +void FLAC::Picture::setType(FLAC::Picture::Type type) { d->type = type; } -String FLAC::Picture::mimeType() const -{ +String FLAC::Picture::mimeType() const { return d->mimeType; } -void FLAC::Picture::setMimeType(const String &mimeType) -{ +void FLAC::Picture::setMimeType(const String &mimeType) { d->mimeType = mimeType; } -String FLAC::Picture::description() const -{ +String FLAC::Picture::description() const { return d->description; } -void FLAC::Picture::setDescription(const String &description) -{ +void FLAC::Picture::setDescription(const String &description) { d->description = description; } -int FLAC::Picture::width() const -{ +int FLAC::Picture::width() const { return d->width; } -void FLAC::Picture::setWidth(int width) -{ +void FLAC::Picture::setWidth(int width) { d->width = width; } -int FLAC::Picture::height() const -{ +int FLAC::Picture::height() const { return d->height; } -void FLAC::Picture::setHeight(int height) -{ +void FLAC::Picture::setHeight(int height) { d->height = height; } -int FLAC::Picture::colorDepth() const -{ +int FLAC::Picture::colorDepth() const { return d->colorDepth; } -void FLAC::Picture::setColorDepth(int colorDepth) -{ +void FLAC::Picture::setColorDepth(int colorDepth) { d->colorDepth = colorDepth; } -int FLAC::Picture::numColors() const -{ +int FLAC::Picture::numColors() const { return d->numColors; } -void FLAC::Picture::setNumColors(int numColors) -{ +void FLAC::Picture::setNumColors(int numColors) { d->numColors = numColors; } -ByteVector FLAC::Picture::data() const -{ +ByteVector FLAC::Picture::data() const { return d->data; } -void FLAC::Picture::setData(const ByteVector &data) -{ +void FLAC::Picture::setData(const ByteVector &data) { d->data = data; } - diff --git a/3rdparty/taglib/flac/flacpicture.h b/3rdparty/taglib/flac/flacpicture.h index 4cb2bf5b1..8ae5781dd 100644 --- a/3rdparty/taglib/flac/flacpicture.h +++ b/3rdparty/taglib/flac/flacpicture.h @@ -35,176 +35,174 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace FLAC { +namespace FLAC { - class TAGLIB_EXPORT Picture : public MetadataBlock - { - public: - - /*! +class TAGLIB_EXPORT Picture : public MetadataBlock { + public: + /*! * This describes the function or content of the picture. */ - enum Type { - //! A type not enumerated below - Other = 0x00, - //! 32x32 PNG image that should be used as the file icon - FileIcon = 0x01, - //! File icon of a different size or format - OtherFileIcon = 0x02, - //! Front cover image of the album - FrontCover = 0x03, - //! Back cover image of the album - BackCover = 0x04, - //! Inside leaflet page of the album - LeafletPage = 0x05, - //! Image from the album itself - Media = 0x06, - //! Picture of the lead artist or soloist - LeadArtist = 0x07, - //! Picture of the artist or performer - Artist = 0x08, - //! Picture of the conductor - Conductor = 0x09, - //! Picture of the band or orchestra - Band = 0x0A, - //! Picture of the composer - Composer = 0x0B, - //! Picture of the lyricist or text writer - Lyricist = 0x0C, - //! Picture of the recording location or studio - RecordingLocation = 0x0D, - //! Picture of the artists during recording - DuringRecording = 0x0E, - //! Picture of the artists during performance - DuringPerformance = 0x0F, - //! Picture from a movie or video related to the track - MovieScreenCapture = 0x10, - //! Picture of a large, coloured fish - ColouredFish = 0x11, - //! Illustration related to the track - Illustration = 0x12, - //! Logo of the band or performer - BandLogo = 0x13, - //! Logo of the publisher (record company) - PublisherLogo = 0x14 - }; + enum Type { + //! A type not enumerated below + Other = 0x00, + //! 32x32 PNG image that should be used as the file icon + FileIcon = 0x01, + //! File icon of a different size or format + OtherFileIcon = 0x02, + //! Front cover image of the album + FrontCover = 0x03, + //! Back cover image of the album + BackCover = 0x04, + //! Inside leaflet page of the album + LeafletPage = 0x05, + //! Image from the album itself + Media = 0x06, + //! Picture of the lead artist or soloist + LeadArtist = 0x07, + //! Picture of the artist or performer + Artist = 0x08, + //! Picture of the conductor + Conductor = 0x09, + //! Picture of the band or orchestra + Band = 0x0A, + //! Picture of the composer + Composer = 0x0B, + //! Picture of the lyricist or text writer + Lyricist = 0x0C, + //! Picture of the recording location or studio + RecordingLocation = 0x0D, + //! Picture of the artists during recording + DuringRecording = 0x0E, + //! Picture of the artists during performance + DuringPerformance = 0x0F, + //! Picture from a movie or video related to the track + MovieScreenCapture = 0x10, + //! Picture of a large, coloured fish + ColouredFish = 0x11, + //! Illustration related to the track + Illustration = 0x12, + //! Logo of the band or performer + BandLogo = 0x13, + //! Logo of the publisher (record company) + PublisherLogo = 0x14 + }; - Picture(); - Picture(const ByteVector &data); - ~Picture(); + Picture(); + Picture(const ByteVector &data); + ~Picture(); - /*! + /*! * Returns the type of the image. */ - Type type() const; + Type type() const; - /*! + /*! * Sets the type of the image. */ - void setType(Type type); + void setType(Type type); - /*! + /*! * Returns the mime type of the image. This should in most cases be * "image/png" or "image/jpeg". */ - String mimeType() const; + String mimeType() const; - /*! + /*! * Sets the mime type of the image. This should in most cases be * "image/png" or "image/jpeg". */ - void setMimeType(const String &m); + void setMimeType(const String &m); - /*! + /*! * Returns a text description of the image. */ - String description() const; + String description() const; - /*! + /*! * Sets a textual description of the image to \a desc. */ - void setDescription(const String &desc); + void setDescription(const String &desc); - /*! + /*! * Returns the width of the image. */ - int width() const; + int width() const; - /*! + /*! * Sets the width of the image. */ - void setWidth(int w); + void setWidth(int w); - /*! + /*! * Returns the height of the image. */ - int height() const; + int height() const; - /*! + /*! * Sets the height of the image. */ - void setHeight(int h); + void setHeight(int h); - /*! + /*! * Returns the color depth (in bits-per-pixel) of the image. */ - int colorDepth() const; + int colorDepth() const; - /*! + /*! * Sets the color depth (in bits-per-pixel) of the image. */ - void setColorDepth(int depth); + void setColorDepth(int depth); - /*! + /*! * Returns the number of colors used on the image.. */ - int numColors() const; + int numColors() const; - /*! + /*! * Sets the number of colors used on the image (for indexed images). */ - void setNumColors(int numColors); + void setNumColors(int numColors); - /*! + /*! * Returns the image data. */ - ByteVector data() const; + ByteVector data() const; - /*! + /*! * Sets the image data. */ - void setData(const ByteVector &data); + void setData(const ByteVector &data); - /*! + /*! * Returns the FLAC metadata block type. */ - int code() const; + int code() const; - /*! + /*! * Render the content to the FLAC picture block format. */ - ByteVector render() const; + ByteVector render() const; - /*! + /*! * Parse the picture data in the FLAC picture block format. */ - bool parse(const ByteVector &rawData); + bool parse(const ByteVector &rawData); - private: - Picture(const Picture &item); - Picture &operator=(const Picture &item); + private: + Picture(const Picture &item); + Picture &operator=(const Picture &item); - class PicturePrivate; - PicturePrivate *d; - }; + class PicturePrivate; + PicturePrivate *d; +}; - typedef List PictureList; +typedef List PictureList; - } +} // namespace FLAC -} -} +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/flac/flacproperties.cpp b/3rdparty/taglib/flac/flacproperties.cpp index 1656c0d87..aff061189 100644 --- a/3rdparty/taglib/flac/flacproperties.cpp +++ b/3rdparty/taglib/flac/flacproperties.cpp @@ -31,16 +31,14 @@ using namespace Strawberry_TagLib::TagLib; -class FLAC::Properties::PropertiesPrivate -{ -public: - PropertiesPrivate() : - length(0), - bitrate(0), - sampleRate(0), - bitsPerSample(0), - channels(0), - sampleFrames(0) {} +class FLAC::Properties::PropertiesPrivate { + public: + PropertiesPrivate() : length(0), + bitrate(0), + sampleRate(0), + bitsPerSample(0), + channels(0), + sampleFrames(0) {} int length; int bitrate; @@ -55,72 +53,57 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -FLAC::Properties::Properties(ByteVector data, long streamLength, ReadStyle style) : - AudioProperties(style), - d(new PropertiesPrivate()) -{ +FLAC::Properties::Properties(ByteVector data, long streamLength, ReadStyle style) : AudioProperties(style), + d(new PropertiesPrivate()) { read(data, streamLength); } -FLAC::Properties::Properties(File *, ReadStyle style) : - AudioProperties(style), - d(new PropertiesPrivate()) -{ +FLAC::Properties::Properties(File *, ReadStyle style) : AudioProperties(style), + d(new PropertiesPrivate()) { debug("FLAC::Properties::Properties() - This constructor is no longer used."); } -FLAC::Properties::~Properties() -{ +FLAC::Properties::~Properties() { delete d; } -int FLAC::Properties::length() const -{ +int FLAC::Properties::length() const { return lengthInSeconds(); } -int FLAC::Properties::lengthInSeconds() const -{ +int FLAC::Properties::lengthInSeconds() const { return d->length / 1000; } -int FLAC::Properties::lengthInMilliseconds() const -{ +int FLAC::Properties::lengthInMilliseconds() const { return d->length; } -int FLAC::Properties::bitrate() const -{ +int FLAC::Properties::bitrate() const { return d->bitrate; } -int FLAC::Properties::sampleRate() const -{ +int FLAC::Properties::sampleRate() const { return d->sampleRate; } -int FLAC::Properties::bitsPerSample() const -{ +int FLAC::Properties::bitsPerSample() const { return d->bitsPerSample; } -int FLAC::Properties::sampleWidth() const -{ +int FLAC::Properties::sampleWidth() const { return bitsPerSample(); } -int FLAC::Properties::channels() const -{ +int FLAC::Properties::channels() const { return d->channels; } -unsigned long long FLAC::Properties::sampleFrames() const -{ +unsigned long long FLAC::Properties::sampleFrames() const { return d->sampleFrames; } -ByteVector FLAC::Properties::signature() const -{ +ByteVector FLAC::Properties::signature() const { return d->signature; } @@ -128,9 +111,8 @@ ByteVector FLAC::Properties::signature() const // private members //////////////////////////////////////////////////////////////////////////////// -void FLAC::Properties::read(const ByteVector &data, long streamLength) -{ - if(data.size() < 18) { +void FLAC::Properties::read(const ByteVector &data, long streamLength) { + if (data.size() < 18) { debug("FLAC::Properties::read() - FLAC properties must contain at least 18 bytes."); return; } @@ -152,8 +134,8 @@ void FLAC::Properties::read(const ByteVector &data, long streamLength) const unsigned int flags = data.toUInt(pos, true); pos += 4; - d->sampleRate = flags >> 12; - d->channels = ((flags >> 9) & 7) + 1; + d->sampleRate = flags >> 12; + d->channels = ((flags >> 9) & 7) + 1; d->bitsPerSample = ((flags >> 4) & 31) + 1; // The last 4 bits are the most significant 4 bits for the 36 bit @@ -165,12 +147,12 @@ void FLAC::Properties::read(const ByteVector &data, long streamLength) d->sampleFrames = (hi << 32) | lo; - if(d->sampleFrames > 0 && d->sampleRate > 0) { + if (d->sampleFrames > 0 && d->sampleRate > 0) { const double length = d->sampleFrames * 1000.0 / d->sampleRate; - d->length = static_cast(length + 0.5); + d->length = static_cast(length + 0.5); d->bitrate = static_cast(streamLength * 8.0 / length + 0.5); } - if(data.size() >= pos + 16) + if (data.size() >= pos + 16) d->signature = data.mid(pos, 16); } diff --git a/3rdparty/taglib/flac/flacproperties.h b/3rdparty/taglib/flac/flacproperties.h index 6a2363372..664e36464 100644 --- a/3rdparty/taglib/flac/flacproperties.h +++ b/3rdparty/taglib/flac/flacproperties.h @@ -32,40 +32,39 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace FLAC { +namespace FLAC { - class File; +class File; - //! An implementation of audio property reading for FLAC +//! An implementation of audio property reading for FLAC - /*! +/*! * This reads the data from an FLAC stream found in the AudioProperties * API. */ - class TAGLIB_EXPORT Properties : public AudioProperties - { - public: - /*! +class TAGLIB_EXPORT Properties : public AudioProperties { + public: + /*! * Create an instance of FLAC::Properties with the data read from the * ByteVector \a data. */ - // BIC: switch to const reference - Properties(ByteVector data, long streamLength, ReadStyle style = Average); + // BIC: switch to const reference + Properties(ByteVector data, long streamLength, ReadStyle style = Average); - /*! + /*! * Create an instance of FLAC::Properties with the data read from the * FLAC::File \a file. */ - // BIC: remove - Properties(File *file, ReadStyle style = Average); + // BIC: remove + Properties(File *file, ReadStyle style = Average); - /*! + /*! * Destroys this FLAC::Properties instance. */ - virtual ~Properties(); + virtual ~Properties(); - /*! + /*! * Returns the length of the file in seconds. The length is rounded down to * the nearest whole second. * @@ -73,47 +72,47 @@ namespace TagLib { * * \deprecated */ - TAGLIB_DEPRECATED virtual int length() const; + TAGLIB_DEPRECATED virtual int length() const; - /*! + /*! * Returns the length of the file in seconds. The length is rounded down to * the nearest whole second. * * \see lengthInMilliseconds() */ - // BIC: make virtual - int lengthInSeconds() const; + // BIC: make virtual + int lengthInSeconds() const; - /*! + /*! * Returns the length of the file in milliseconds. * * \see lengthInSeconds() */ - // BIC: make virtual - int lengthInMilliseconds() const; + // BIC: make virtual + int lengthInMilliseconds() const; - /*! + /*! * Returns the average bit rate of the file in kb/s. */ - virtual int bitrate() const; + virtual int bitrate() const; - /*! + /*! * Returns the sample rate in Hz. */ - virtual int sampleRate() const; + virtual int sampleRate() const; - /*! + /*! * Returns the number of audio channels. */ - virtual int channels() const; + virtual int channels() const; - /*! + /*! * Returns the number of bits per audio sample as read from the FLAC * identification header. */ - int bitsPerSample() const; + int bitsPerSample() const; - /*! + /*! * Returns the sample width as read from the FLAC identification * header. * @@ -121,30 +120,30 @@ namespace TagLib { * * \deprecated */ - TAGLIB_DEPRECATED int sampleWidth() const; + TAGLIB_DEPRECATED int sampleWidth() const; - /*! + /*! * Return the number of sample frames. */ - unsigned long long sampleFrames() const; + unsigned long long sampleFrames() const; - /*! + /*! * Returns the MD5 signature of the uncompressed audio stream as read * from the stream info header. */ - ByteVector signature() const; + ByteVector signature() const; - private: - Properties(const Properties &); - Properties &operator=(const Properties &); + private: + Properties(const Properties &); + Properties &operator=(const Properties &); - void read(const ByteVector &data, long streamLength); + void read(const ByteVector &data, long streamLength); - class PropertiesPrivate; - PropertiesPrivate *d; - }; - } -} -} + class PropertiesPrivate; + PropertiesPrivate *d; +}; +} // namespace FLAC +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/flac/flacunknownmetadatablock.cpp b/3rdparty/taglib/flac/flacunknownmetadatablock.cpp index 4aa257337..9534c0ec3 100644 --- a/3rdparty/taglib/flac/flacunknownmetadatablock.cpp +++ b/3rdparty/taglib/flac/flacunknownmetadatablock.cpp @@ -30,49 +30,39 @@ using namespace Strawberry_TagLib::TagLib; -class FLAC::UnknownMetadataBlock::UnknownMetadataBlockPrivate -{ -public: +class FLAC::UnknownMetadataBlock::UnknownMetadataBlockPrivate { + public: UnknownMetadataBlockPrivate() : code(0) {} int code; ByteVector data; }; -FLAC::UnknownMetadataBlock::UnknownMetadataBlock(int code, const ByteVector &data) : - d(new UnknownMetadataBlockPrivate()) -{ +FLAC::UnknownMetadataBlock::UnknownMetadataBlock(int code, const ByteVector &data) : d(new UnknownMetadataBlockPrivate()) { d->code = code; d->data = data; } -FLAC::UnknownMetadataBlock::~UnknownMetadataBlock() -{ +FLAC::UnknownMetadataBlock::~UnknownMetadataBlock() { delete d; } -int FLAC::UnknownMetadataBlock::code() const -{ +int FLAC::UnknownMetadataBlock::code() const { return d->code; } -void FLAC::UnknownMetadataBlock::setCode(int code) -{ +void FLAC::UnknownMetadataBlock::setCode(int code) { d->code = code; } -ByteVector FLAC::UnknownMetadataBlock::data() const -{ +ByteVector FLAC::UnknownMetadataBlock::data() const { return d->data; } -void FLAC::UnknownMetadataBlock::setData(const ByteVector &data) -{ +void FLAC::UnknownMetadataBlock::setData(const ByteVector &data) { d->data = data; } -ByteVector FLAC::UnknownMetadataBlock::render() const -{ +ByteVector FLAC::UnknownMetadataBlock::render() const { return d->data; } - diff --git a/3rdparty/taglib/flac/flacunknownmetadatablock.h b/3rdparty/taglib/flac/flacunknownmetadatablock.h index 010f983f6..d79cf6d4b 100644 --- a/3rdparty/taglib/flac/flacunknownmetadatablock.h +++ b/3rdparty/taglib/flac/flacunknownmetadatablock.h @@ -34,50 +34,49 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace FLAC { +namespace FLAC { - class TAGLIB_EXPORT UnknownMetadataBlock : public MetadataBlock - { - public: - UnknownMetadataBlock(int blockType, const ByteVector &data); - ~UnknownMetadataBlock(); +class TAGLIB_EXPORT UnknownMetadataBlock : public MetadataBlock { + public: + UnknownMetadataBlock(int blockType, const ByteVector &data); + ~UnknownMetadataBlock(); - /*! + /*! * Returns the FLAC metadata block type. */ - int code() const; + int code() const; - /*! + /*! * Sets the FLAC metadata block type. */ - void setCode(int code); + void setCode(int code); - /*! + /*! * Returns the FLAC metadata block type. */ - ByteVector data() const; + ByteVector data() const; - /*! + /*! * Sets the FLAC metadata block type. */ - void setData(const ByteVector &data); + void setData(const ByteVector &data); - /*! + /*! * Render the content of the block. */ - ByteVector render() const; + ByteVector render() const; - private: - UnknownMetadataBlock(const MetadataBlock &item); - UnknownMetadataBlock &operator=(const MetadataBlock &item); + private: + UnknownMetadataBlock(const MetadataBlock &item); + UnknownMetadataBlock &operator=(const MetadataBlock &item); - class UnknownMetadataBlockPrivate; - UnknownMetadataBlockPrivate *d; - }; + class UnknownMetadataBlockPrivate; + UnknownMetadataBlockPrivate *d; +}; - } +} // namespace FLAC -} -} +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/it/itfile.cpp b/3rdparty/taglib/it/itfile.cpp index a05ae5afc..6f1557d18 100644 --- a/3rdparty/taglib/it/itfile.cpp +++ b/3rdparty/taglib/it/itfile.cpp @@ -33,65 +33,52 @@ using namespace Strawberry_TagLib::TagLib; using namespace IT; -class IT::File::FilePrivate -{ -public: +class IT::File::FilePrivate { + public: explicit FilePrivate(AudioProperties::ReadStyle propertiesStyle) - : tag(), properties(propertiesStyle) - { + : tag(), properties(propertiesStyle) { } - Mod::Tag tag; + Mod::Tag tag; IT::Properties properties; }; IT::File::File(FileName file, bool readProperties, - AudioProperties::ReadStyle propertiesStyle) : - Mod::FileBase(file), - d(new FilePrivate(propertiesStyle)) -{ - if(isOpen()) + AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(file), + d(new FilePrivate(propertiesStyle)) { + if (isOpen()) read(readProperties); } IT::File::File(IOStream *stream, bool readProperties, - AudioProperties::ReadStyle propertiesStyle) : - Mod::FileBase(stream), - d(new FilePrivate(propertiesStyle)) -{ - if(isOpen()) + AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(stream), + d(new FilePrivate(propertiesStyle)) { + if (isOpen()) read(readProperties); } -IT::File::~File() -{ +IT::File::~File() { delete d; } -Mod::Tag *IT::File::tag() const -{ +Mod::Tag *IT::File::tag() const { return &d->tag; } -PropertyMap IT::File::properties() const -{ +PropertyMap IT::File::properties() const { return d->tag.properties(); } -PropertyMap IT::File::setProperties(const PropertyMap &properties) -{ +PropertyMap IT::File::setProperties(const PropertyMap &properties) { return d->tag.setProperties(properties); } -IT::Properties *IT::File::audioProperties() const -{ +IT::Properties *IT::File::audioProperties() const { return &d->properties; } -bool IT::File::save() -{ - if(readOnly()) - { +bool IT::File::save() { + if (readOnly()) { debug("IT::File::save() - Cannot save to a read only file."); return false; } @@ -105,37 +92,37 @@ bool IT::File::save() unsigned short instrumentCount = 0; unsigned short sampleCount = 0; - if(!readU16L(length) || !readU16L(instrumentCount) || !readU16L(sampleCount)) + if (!readU16L(length) || !readU16L(instrumentCount) || !readU16L(sampleCount)) return false; seek(15, Current); // write comment as instrument and sample names: StringList lines = d->tag.comment().split("\n"); - for(unsigned short i = 0; i < instrumentCount; ++ i) { + for (unsigned short i = 0; i < instrumentCount; ++i) { seek(192L + length + ((long)i << 2)); unsigned long instrumentOffset = 0; - if(!readU32L(instrumentOffset)) + if (!readU32L(instrumentOffset)) return false; seek(instrumentOffset + 32); - if(i < lines.size()) + if (i < lines.size()) writeString(lines[i], 25); else writeString(String(), 25); writeByte(0); } - for(unsigned short i = 0; i < sampleCount; ++ i) { + for (unsigned short i = 0; i < sampleCount; ++i) { seek(192L + length + ((long)instrumentCount << 2) + ((long)i << 2)); unsigned long sampleOffset = 0; - if(!readU32L(sampleOffset)) + if (!readU32L(sampleOffset)) return false; seek(sampleOffset + 20); - if((unsigned int)(i + instrumentCount) < lines.size()) + if ((unsigned int)(i + instrumentCount) < lines.size()) writeString(lines[i + instrumentCount], 25); else writeString(String(), 25); @@ -144,41 +131,40 @@ bool IT::File::save() // write rest as message: StringList messageLines; - for(unsigned int i = instrumentCount + sampleCount; i < lines.size(); ++ i) + for (unsigned int i = instrumentCount + sampleCount; i < lines.size(); ++i) messageLines.append(lines[i]); ByteVector message = messageLines.toString("\r").data(String::Latin1); // it's actually not really stated if the message needs a // terminating NUL but it does not hurt to add one: - if(message.size() > 7999) + if (message.size() > 7999) message.resize(7999); message.append((char)0); unsigned short special = 0; unsigned short messageLength = 0; - unsigned long messageOffset = 0; + unsigned long messageOffset = 0; seek(46); - if(!readU16L(special)) + if (!readU16L(special)) return false; unsigned long fileSize = File::length(); - if(special & Properties::MessageAttached) { + if (special & Properties::MessageAttached) { seek(54); - if(!readU16L(messageLength) || !readU32L(messageOffset)) + if (!readU16L(messageLength) || !readU32L(messageOffset)) return false; - if(messageLength == 0) + if (messageLength == 0) messageOffset = fileSize; } - else - { + else { messageOffset = fileSize; seek(46); writeU16L(special | 0x1); } - if(messageOffset + messageLength >= fileSize) { + if (messageOffset + messageLength >= fileSize) { // append new message seek(54); writeU16L(message.size()); @@ -199,9 +185,8 @@ bool IT::File::save() return true; } -void IT::File::read(bool) -{ - if(!isOpen()) +void IT::File::read(bool) { + if (!isOpen()) return; seek(0); @@ -233,14 +218,14 @@ void IT::File::read(bool) // sample/instrument names are abused as comments so // I just add all together. String message; - if(special & Properties::MessageAttached) { + if (special & Properties::MessageAttached) { READ_U16L_AS(messageLength); READ_U32L_AS(messageOffset); seek(messageOffset); ByteVector messageBytes = readBlock(messageLength); READ_ASSERT(messageBytes.size() == messageLength); - int index = messageBytes.find((char) 0); - if(index > -1) + int index = messageBytes.find((char)0); + if (index > -1) messageBytes.resize(index, 0); messageBytes.replace('\r', '\n'); message = messageBytes; @@ -249,26 +234,26 @@ void IT::File::read(bool) seek(64); ByteVector pannings = readBlock(64); - ByteVector volumes = readBlock(64); + ByteVector volumes = readBlock(64); READ_ASSERT(pannings.size() == 64 && volumes.size() == 64); int channels = 0; - for(int i = 0; i < 64; ++ i) { + for (int i = 0; i < 64; ++i) { // Strictly speaking an IT file has always 64 channels, but // I don't count disabled and muted channels. // But this always gives 64 channels for all my files anyway. // Strangely VLC does report other values. I wonder how VLC // gets it's values. - if((unsigned char) pannings[i] < 128 && volumes[i] > 0) - ++channels; + if ((unsigned char)pannings[i] < 128 && volumes[i] > 0) + ++channels; } d->properties.setChannels(channels); // real length might be shorter because of skips and terminator unsigned short realLength = 0; - for(unsigned short i = 0; i < length; ++ i) { + for (unsigned short i = 0; i < length; ++i) { READ_BYTE_AS(order); - if(order == 255) break; - if(order != 254) ++ realLength; + if (order == 255) break; + if (order != 254) ++realLength; } d->properties.setLengthInPatterns(realLength); @@ -279,7 +264,7 @@ void IT::File::read(bool) // Currently I just discard anything after a nil, but // e.g. VLC seems to interpret a nil as a space. I // don't know what is the proper behaviour. - for(unsigned short i = 0; i < instrumentCount; ++ i) { + for (unsigned short i = 0; i < instrumentCount; ++i) { seek(192L + length + ((long)i << 2)); READ_U32L_AS(instrumentOffset); seek(instrumentOffset); @@ -295,7 +280,7 @@ void IT::File::read(bool) comment.append(instrumentName); } - for(unsigned short i = 0; i < sampleCount; ++ i) { + for (unsigned short i = 0; i < sampleCount; ++i) { seek(192L + length + ((long)instrumentCount << 2) + ((long)i << 2)); READ_U32L_AS(sampleOffset); @@ -328,7 +313,7 @@ void IT::File::read(bool) comment.append(sampleName); } - if(message.size() > 0) + if (message.size() > 0) comment.append(message); d->tag.setComment(comment.toString("\n")); d->tag.setTrackerName("Impulse Tracker"); diff --git a/3rdparty/taglib/it/itfile.h b/3rdparty/taglib/it/itfile.h index d47d609f2..e1393d4ae 100644 --- a/3rdparty/taglib/it/itfile.h +++ b/3rdparty/taglib/it/itfile.h @@ -32,22 +32,22 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace IT { +namespace IT { - class TAGLIB_EXPORT File : public Mod::FileBase { - public: - /*! +class TAGLIB_EXPORT File : public Mod::FileBase { + public: + /*! * Constructs a Impulse Tracker file from \a file. * * \note In the current implementation, both \a readProperties and * \a propertiesStyle are ignored. The audio properties are always * read. */ - File(FileName file, bool readProperties = true, - AudioProperties::ReadStyle propertiesStyle = - AudioProperties::Average); + File(FileName file, bool readProperties = true, + AudioProperties::ReadStyle propertiesStyle = + AudioProperties::Average); - /*! + /*! * Constructs a Impulse Tracker file from \a stream. * * \note In the current implementation, both \a readProperties and @@ -57,55 +57,55 @@ namespace TagLib { * \note TagLib will *not* take ownership of the stream, the caller is * responsible for deleting it after the File object. */ - File(IOStream *stream, bool readProperties = true, - AudioProperties::ReadStyle propertiesStyle = - AudioProperties::Average); + File(IOStream *stream, bool readProperties = true, + AudioProperties::ReadStyle propertiesStyle = + AudioProperties::Average); - /*! + /*! * Destroys this instance of the File. */ - virtual ~File(); + virtual ~File(); - Mod::Tag *tag() const; + Mod::Tag *tag() const; - /*! + /*! * Forwards to Mod::Tag::properties(). * BIC: will be removed once File::toDict() is made virtual */ - PropertyMap properties() const; + PropertyMap properties() const; - /*! + /*! * Forwards to Mod::Tag::setProperties(). * BIC: will be removed once File::setProperties() is made virtual */ - PropertyMap setProperties(const PropertyMap &); + PropertyMap setProperties(const PropertyMap &); - /*! + /*! * Returns the IT::Properties for this file. If no audio properties * were read then this will return a null pointer. */ - IT::Properties *audioProperties() const; + IT::Properties *audioProperties() const; - /*! + /*! * Save the file. * This is the same as calling save(AllTags); * * \note Saving Impulse Tracker tags is not supported. */ - bool save(); + bool save(); - private: - File(const File &); - File &operator=(const File &); + private: + File(const File &); + File &operator=(const File &); - void read(bool readProperties); + void read(bool readProperties); - class FilePrivate; - FilePrivate *d; - }; - } -} -} + class FilePrivate; + FilePrivate *d; +}; +} // namespace IT +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/it/itproperties.cpp b/3rdparty/taglib/it/itproperties.cpp index 99687c919..bbe765228 100644 --- a/3rdparty/taglib/it/itproperties.cpp +++ b/3rdparty/taglib/it/itproperties.cpp @@ -29,29 +29,26 @@ using namespace Strawberry_TagLib::TagLib; using namespace IT; -class IT::Properties::PropertiesPrivate -{ -public: - PropertiesPrivate() : - channels(0), - lengthInPatterns(0), - instrumentCount(0), - sampleCount(0), - patternCount(0), - version(0), - compatibleVersion(0), - flags(0), - special(0), - globalVolume(0), - mixVolume(0), - tempo(0), - bpmSpeed(0), - panningSeparation(0), - pitchWheelDepth(0) - { +class IT::Properties::PropertiesPrivate { + public: + PropertiesPrivate() : channels(0), + lengthInPatterns(0), + instrumentCount(0), + sampleCount(0), + patternCount(0), + version(0), + compatibleVersion(0), + flags(0), + special(0), + globalVolume(0), + mixVolume(0), + tempo(0), + bpmSpeed(0), + panningSeparation(0), + pitchWheelDepth(0) { } - int channels; + int channels; unsigned short lengthInPatterns; unsigned short instrumentCount; unsigned short sampleCount; @@ -60,201 +57,162 @@ public: unsigned short compatibleVersion; unsigned short flags; unsigned short special; - unsigned char globalVolume; - unsigned char mixVolume; - unsigned char tempo; - unsigned char bpmSpeed; - unsigned char panningSeparation; - unsigned char pitchWheelDepth; + unsigned char globalVolume; + unsigned char mixVolume; + unsigned char tempo; + unsigned char bpmSpeed; + unsigned char panningSeparation; + unsigned char pitchWheelDepth; }; -IT::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) : - AudioProperties(propertiesStyle), - d(new PropertiesPrivate()) -{ +IT::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) : AudioProperties(propertiesStyle), + d(new PropertiesPrivate()) { } -IT::Properties::~Properties() -{ +IT::Properties::~Properties() { delete d; } -int IT::Properties::length() const -{ +int IT::Properties::length() const { return 0; } -int IT::Properties::lengthInSeconds() const -{ +int IT::Properties::lengthInSeconds() const { return 0; } -int IT::Properties::lengthInMilliseconds() const -{ +int IT::Properties::lengthInMilliseconds() const { return 0; } -int IT::Properties::bitrate() const -{ +int IT::Properties::bitrate() const { return 0; } -int IT::Properties::sampleRate() const -{ +int IT::Properties::sampleRate() const { return 0; } -int IT::Properties::channels() const -{ +int IT::Properties::channels() const { return d->channels; } -unsigned short IT::Properties::lengthInPatterns() const -{ +unsigned short IT::Properties::lengthInPatterns() const { return d->lengthInPatterns; } -bool IT::Properties::stereo() const -{ +bool IT::Properties::stereo() const { return d->flags & Stereo; } -unsigned short IT::Properties::instrumentCount() const -{ +unsigned short IT::Properties::instrumentCount() const { return d->instrumentCount; } -unsigned short IT::Properties::sampleCount() const -{ +unsigned short IT::Properties::sampleCount() const { return d->sampleCount; } -unsigned short IT::Properties::patternCount() const -{ +unsigned short IT::Properties::patternCount() const { return d->patternCount; } -unsigned short IT::Properties::version() const -{ +unsigned short IT::Properties::version() const { return d->version; } -unsigned short IT::Properties::compatibleVersion() const -{ +unsigned short IT::Properties::compatibleVersion() const { return d->compatibleVersion; } -unsigned short IT::Properties::flags() const -{ +unsigned short IT::Properties::flags() const { return d->flags; } -unsigned short IT::Properties::special() const -{ +unsigned short IT::Properties::special() const { return d->special; } -unsigned char IT::Properties::globalVolume() const -{ +unsigned char IT::Properties::globalVolume() const { return d->globalVolume; } -unsigned char IT::Properties::mixVolume() const -{ +unsigned char IT::Properties::mixVolume() const { return d->mixVolume; } -unsigned char IT::Properties::tempo() const -{ +unsigned char IT::Properties::tempo() const { return d->tempo; } -unsigned char IT::Properties::bpmSpeed() const -{ +unsigned char IT::Properties::bpmSpeed() const { return d->bpmSpeed; } -unsigned char IT::Properties::panningSeparation() const -{ +unsigned char IT::Properties::panningSeparation() const { return d->panningSeparation; } -unsigned char IT::Properties::pitchWheelDepth() const -{ +unsigned char IT::Properties::pitchWheelDepth() const { return d->pitchWheelDepth; } -void IT::Properties::setChannels(int channels) -{ +void IT::Properties::setChannels(int channels) { d->channels = channels; } -void IT::Properties::setLengthInPatterns(unsigned short lengthInPatterns) -{ +void IT::Properties::setLengthInPatterns(unsigned short lengthInPatterns) { d->lengthInPatterns = lengthInPatterns; } -void IT::Properties::setInstrumentCount(unsigned short instrumentCount) -{ +void IT::Properties::setInstrumentCount(unsigned short instrumentCount) { d->instrumentCount = instrumentCount; } -void IT::Properties::setSampleCount(unsigned short sampleCount) -{ +void IT::Properties::setSampleCount(unsigned short sampleCount) { d->sampleCount = sampleCount; } -void IT::Properties::setPatternCount(unsigned short patternCount) -{ +void IT::Properties::setPatternCount(unsigned short patternCount) { d->patternCount = patternCount; } -void IT::Properties::setFlags(unsigned short flags) -{ +void IT::Properties::setFlags(unsigned short flags) { d->flags = flags; } -void IT::Properties::setSpecial(unsigned short special) -{ +void IT::Properties::setSpecial(unsigned short special) { d->special = special; } -void IT::Properties::setCompatibleVersion(unsigned short compatibleVersion) -{ +void IT::Properties::setCompatibleVersion(unsigned short compatibleVersion) { d->compatibleVersion = compatibleVersion; } -void IT::Properties::setVersion(unsigned short version) -{ +void IT::Properties::setVersion(unsigned short version) { d->version = version; } -void IT::Properties::setGlobalVolume(unsigned char globalVolume) -{ +void IT::Properties::setGlobalVolume(unsigned char globalVolume) { d->globalVolume = globalVolume; } -void IT::Properties::setMixVolume(unsigned char mixVolume) -{ +void IT::Properties::setMixVolume(unsigned char mixVolume) { d->mixVolume = mixVolume; } -void IT::Properties::setTempo(unsigned char tempo) -{ +void IT::Properties::setTempo(unsigned char tempo) { d->tempo = tempo; } -void IT::Properties::setBpmSpeed(unsigned char bpmSpeed) -{ +void IT::Properties::setBpmSpeed(unsigned char bpmSpeed) { d->bpmSpeed = bpmSpeed; } -void IT::Properties::setPanningSeparation(unsigned char panningSeparation) -{ +void IT::Properties::setPanningSeparation(unsigned char panningSeparation) { d->panningSeparation = panningSeparation; } -void IT::Properties::setPitchWheelDepth(unsigned char pitchWheelDepth) -{ +void IT::Properties::setPitchWheelDepth(unsigned char pitchWheelDepth) { d->pitchWheelDepth = pitchWheelDepth; } diff --git a/3rdparty/taglib/it/itproperties.h b/3rdparty/taglib/it/itproperties.h index 47701c8c4..6c6f81c90 100644 --- a/3rdparty/taglib/it/itproperties.h +++ b/3rdparty/taglib/it/itproperties.h @@ -31,79 +31,80 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace IT { - class TAGLIB_EXPORT Properties : public AudioProperties { - friend class File; - public: - /*! Flag bits. */ - enum { - Stereo = 1, - Vol0MixOptimizations = 2, - UseInstruments = 4, - LinearSlides = 8, - OldEffects = 16, - LinkEffects = 32, - UseMidiPitchController = 64, - RequestEmbeddedMidiConf = 128 - }; +namespace IT { +class TAGLIB_EXPORT Properties : public AudioProperties { + friend class File; - /*! Special bits. */ - enum { - MessageAttached = 1, - MidiConfEmbedded = 8 - }; + public: + /*! Flag bits. */ + enum { + Stereo = 1, + Vol0MixOptimizations = 2, + UseInstruments = 4, + LinearSlides = 8, + OldEffects = 16, + LinkEffects = 32, + UseMidiPitchController = 64, + RequestEmbeddedMidiConf = 128 + }; - Properties(AudioProperties::ReadStyle propertiesStyle); - virtual ~Properties(); + /*! Special bits. */ + enum { + MessageAttached = 1, + MidiConfEmbedded = 8 + }; - int length() const; - int lengthInSeconds() const; - int lengthInMilliseconds() const; - int bitrate() const; - int sampleRate() const; - int channels() const; + Properties(AudioProperties::ReadStyle propertiesStyle); + virtual ~Properties(); - unsigned short lengthInPatterns() const; - bool stereo() const; - unsigned short instrumentCount() const; - unsigned short sampleCount() const; - unsigned short patternCount() const; - unsigned short version() const; - unsigned short compatibleVersion() const; - unsigned short flags() const; - unsigned short special() const; - unsigned char globalVolume() const; - unsigned char mixVolume() const; - unsigned char tempo() const; - unsigned char bpmSpeed() const; - unsigned char panningSeparation() const; - unsigned char pitchWheelDepth() const; + int length() const; + int lengthInSeconds() const; + int lengthInMilliseconds() const; + int bitrate() const; + int sampleRate() const; + int channels() const; - void setChannels(int channels); - void setLengthInPatterns(unsigned short lengthInPatterns); - void setInstrumentCount(unsigned short instrumentCount); - void setSampleCount (unsigned short sampleCount); - void setPatternCount(unsigned short patternCount); - void setVersion (unsigned short version); - void setCompatibleVersion(unsigned short compatibleVersion); - void setFlags (unsigned short flags); - void setSpecial (unsigned short special); - void setGlobalVolume(unsigned char globalVolume); - void setMixVolume (unsigned char mixVolume); - void setTempo (unsigned char tempo); - void setBpmSpeed (unsigned char bpmSpeed); - void setPanningSeparation(unsigned char panningSeparation); - void setPitchWheelDepth (unsigned char pitchWheelDepth); + unsigned short lengthInPatterns() const; + bool stereo() const; + unsigned short instrumentCount() const; + unsigned short sampleCount() const; + unsigned short patternCount() const; + unsigned short version() const; + unsigned short compatibleVersion() const; + unsigned short flags() const; + unsigned short special() const; + unsigned char globalVolume() const; + unsigned char mixVolume() const; + unsigned char tempo() const; + unsigned char bpmSpeed() const; + unsigned char panningSeparation() const; + unsigned char pitchWheelDepth() const; - private: - Properties(const Properties&); - Properties &operator=(const Properties&); + void setChannels(int channels); + void setLengthInPatterns(unsigned short lengthInPatterns); + void setInstrumentCount(unsigned short instrumentCount); + void setSampleCount(unsigned short sampleCount); + void setPatternCount(unsigned short patternCount); + void setVersion(unsigned short version); + void setCompatibleVersion(unsigned short compatibleVersion); + void setFlags(unsigned short flags); + void setSpecial(unsigned short special); + void setGlobalVolume(unsigned char globalVolume); + void setMixVolume(unsigned char mixVolume); + void setTempo(unsigned char tempo); + void setBpmSpeed(unsigned char bpmSpeed); + void setPanningSeparation(unsigned char panningSeparation); + void setPitchWheelDepth(unsigned char pitchWheelDepth); - class PropertiesPrivate; - PropertiesPrivate *d; - }; - } -} -} + private: + Properties(const Properties &); + Properties &operator=(const Properties &); + + class PropertiesPrivate; + PropertiesPrivate *d; +}; +} // namespace IT +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mod/modfile.cpp b/3rdparty/taglib/mod/modfile.cpp index a9499209a..c9db57e5b 100644 --- a/3rdparty/taglib/mod/modfile.cpp +++ b/3rdparty/taglib/mod/modfile.cpp @@ -33,64 +33,52 @@ using namespace Strawberry_TagLib::TagLib; using namespace Mod; -class Mod::File::FilePrivate -{ -public: +class Mod::File::FilePrivate { + public: explicit FilePrivate(AudioProperties::ReadStyle propertiesStyle) - : properties(propertiesStyle) - { + : properties(propertiesStyle) { } - Mod::Tag tag; + Mod::Tag tag; Mod::Properties properties; }; Mod::File::File(FileName file, bool readProperties, - AudioProperties::ReadStyle propertiesStyle) : - Mod::FileBase(file), - d(new FilePrivate(propertiesStyle)) -{ - if(isOpen()) + AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(file), + d(new FilePrivate(propertiesStyle)) { + if (isOpen()) read(readProperties); } Mod::File::File(IOStream *stream, bool readProperties, - AudioProperties::ReadStyle propertiesStyle) : - Mod::FileBase(stream), - d(new FilePrivate(propertiesStyle)) -{ - if(isOpen()) + AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(stream), + d(new FilePrivate(propertiesStyle)) { + if (isOpen()) read(readProperties); } -Mod::File::~File() -{ +Mod::File::~File() { delete d; } -Mod::Tag *Mod::File::tag() const -{ +Mod::Tag *Mod::File::tag() const { return &d->tag; } -Mod::Properties *Mod::File::audioProperties() const -{ +Mod::Properties *Mod::File::audioProperties() const { return &d->properties; } -PropertyMap Mod::File::properties() const -{ +PropertyMap Mod::File::properties() const { return d->tag.properties(); } -PropertyMap Mod::File::setProperties(const PropertyMap &properties) -{ +PropertyMap Mod::File::setProperties(const PropertyMap &properties) { return d->tag.setProperties(properties); } -bool Mod::File::save() -{ - if(readOnly()) { +bool Mod::File::save() { + if (readOnly()) { debug("Mod::File::save() - Cannot save to a read only file."); return false; } @@ -98,50 +86,49 @@ bool Mod::File::save() writeString(d->tag.title(), 20); StringList lines = d->tag.comment().split("\n"); unsigned int n = std::min(lines.size(), d->properties.instrumentCount()); - for(unsigned int i = 0; i < n; ++ i) { + for (unsigned int i = 0; i < n; ++i) { writeString(lines[i], 22); seek(8, Current); } - for(unsigned int i = n; i < d->properties.instrumentCount(); ++ i) { + for (unsigned int i = n; i < d->properties.instrumentCount(); ++i) { writeString(String(), 22); seek(8, Current); } return true; } -void Mod::File::read(bool) -{ - if(!isOpen()) +void Mod::File::read(bool) { + if (!isOpen()) return; seek(1080); ByteVector modId = readBlock(4); READ_ASSERT(modId.size() == 4); - int channels = 4; + int channels = 4; unsigned int instruments = 31; - if(modId == "M.K." || modId == "M!K!" || modId == "M&K!" || modId == "N.T.") { + if (modId == "M.K." || modId == "M!K!" || modId == "M&K!" || modId == "N.T.") { d->tag.setTrackerName("ProTracker"); channels = 4; } - else if(modId.startsWith("FLT") || modId.startsWith("TDZ")) { + else if (modId.startsWith("FLT") || modId.startsWith("TDZ")) { d->tag.setTrackerName("StarTrekker"); char digit = modId[3]; READ_ASSERT(digit >= '0' && digit <= '9'); channels = digit - '0'; } - else if(modId.endsWith("CHN")) { + else if (modId.endsWith("CHN")) { d->tag.setTrackerName("StarTrekker"); char digit = modId[0]; READ_ASSERT(digit >= '0' && digit <= '9'); channels = digit - '0'; } - else if(modId == "CD81" || modId == "OKTA") { + else if (modId == "CD81" || modId == "OKTA") { d->tag.setTrackerName("Atari Oktalyzer"); channels = 8; } - else if(modId.endsWith("CH") || modId.endsWith("CN")) { + else if (modId.endsWith("CH") || modId.endsWith("CN")) { d->tag.setTrackerName("TakeTracker"); char digit = modId[0]; READ_ASSERT(digit >= '0' && digit <= '9'); @@ -153,8 +140,8 @@ void Mod::File::read(bool) else { // Not sure if this is correct. I'd need a file // created with NoiseTracker to check this. - d->tag.setTrackerName("NoiseTracker"); // probably - channels = 4; + d->tag.setTrackerName("NoiseTracker"); // probably + channels = 4; instruments = 15; } d->properties.setChannels(channels); @@ -164,7 +151,7 @@ void Mod::File::read(bool) READ_STRING(d->tag.setTitle, 20); StringList comment; - for(unsigned int i = 0; i < instruments; ++ i) { + for (unsigned int i = 0; i < instruments; ++i) { READ_STRING_AS(instrumentName, 22); // value in words, * 2 (<< 1) for bytes: READ_U16B_AS(sampleLength); @@ -172,10 +159,10 @@ void Mod::File::read(bool) READ_BYTE_AS(fineTuneByte); int fineTune = fineTuneByte & 0xF; // > 7 means negative value - if(fineTune > 7) fineTune -= 16; + if (fineTune > 7) fineTune -= 16; READ_BYTE_AS(volume); - if(volume > 64) volume = 64; + if (volume > 64) volume = 64; // volume in decibels: 20 * log10(volume / 64) // value in words, * 2 (<< 1) for bytes: diff --git a/3rdparty/taglib/mod/modfile.h b/3rdparty/taglib/mod/modfile.h index 68fbdc872..37ce9cff4 100644 --- a/3rdparty/taglib/mod/modfile.h +++ b/3rdparty/taglib/mod/modfile.h @@ -36,23 +36,22 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace Mod { +namespace Mod { - class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::Mod::FileBase - { - public: - /*! +class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::Mod::FileBase { + public: + /*! * Constructs a Protracker file from \a file. * * \note In the current implementation, both \a readProperties and * \a propertiesStyle are ignored. The audio properties are always * read. */ - File(FileName file, bool readProperties = true, - AudioProperties::ReadStyle propertiesStyle = - AudioProperties::Average); + File(FileName file, bool readProperties = true, + AudioProperties::ReadStyle propertiesStyle = + AudioProperties::Average); - /*! + /*! * Constructs a Protracker file from \a stream. * * \note In the current implementation, both \a readProperties and @@ -62,55 +61,55 @@ namespace TagLib { * \note TagLib will *not* take ownership of the stream, the caller is * responsible for deleting it after the File object. */ - File(IOStream *stream, bool readProperties = true, - AudioProperties::ReadStyle propertiesStyle = - AudioProperties::Average); + File(IOStream *stream, bool readProperties = true, + AudioProperties::ReadStyle propertiesStyle = + AudioProperties::Average); - /*! + /*! * Destroys this instance of the File. */ - virtual ~File(); + virtual ~File(); - Mod::Tag *tag() const; + Mod::Tag *tag() const; - /*! + /*! * Implements the unified property interface -- export function. * Forwards to Mod::Tag::properties(). */ - PropertyMap properties() const; + PropertyMap properties() const; - /*! + /*! * Implements the unified property interface -- import function. * Forwards to Mod::Tag::setProperties(). */ - PropertyMap setProperties(const PropertyMap &); - /*! + PropertyMap setProperties(const PropertyMap &); + /*! * Returns the Mod::Properties for this file. If no audio properties * were read then this will return a null pointer. */ - Mod::Properties *audioProperties() const; + Mod::Properties *audioProperties() const; - /*! + /*! * Save the file. * This is the same as calling save(AllTags); * * \note Saving Protracker tags is not supported. */ - bool save(); + bool save(); - private: - File(const File &); - File &operator=(const File &); + private: + File(const File &); + File &operator=(const File &); - void read(bool readProperties); + void read(bool readProperties); - class FilePrivate; - FilePrivate *d; - }; + class FilePrivate; + FilePrivate *d; +}; - } +} // namespace Mod -} -} +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mod/modfilebase.cpp b/3rdparty/taglib/mod/modfilebase.cpp index 95624ab2e..36a0bfe13 100644 --- a/3rdparty/taglib/mod/modfilebase.cpp +++ b/3rdparty/taglib/mod/modfilebase.cpp @@ -30,28 +30,23 @@ using namespace Strawberry_TagLib::TagLib; using namespace Mod; -Mod::FileBase::FileBase(FileName file) : Strawberry_TagLib::TagLib::File(file) -{ +Mod::FileBase::FileBase(FileName file) : Strawberry_TagLib::TagLib::File(file) { } -Mod::FileBase::FileBase(IOStream *stream) : Strawberry_TagLib::TagLib::File(stream) -{ +Mod::FileBase::FileBase(IOStream *stream) : Strawberry_TagLib::TagLib::File(stream) { } -void Mod::FileBase::writeString(const String &s, unsigned long size, char padding) -{ +void Mod::FileBase::writeString(const String &s, unsigned long size, char padding) { ByteVector data(s.data(String::Latin1)); data.resize(size, padding); writeBlock(data); } -bool Mod::FileBase::readString(String &s, unsigned long size) -{ +bool Mod::FileBase::readString(String &s, unsigned long size) { ByteVector data(readBlock(size)); - if(data.size() < size) return false; - int index = data.find((char) 0); - if(index > -1) - { + if (data.size() < size) return false; + int index = data.find((char)0); + if (index > -1) { data.resize(index); } data.replace('\xff', ' '); @@ -60,66 +55,58 @@ bool Mod::FileBase::readString(String &s, unsigned long size) return true; } -void Mod::FileBase::writeByte(unsigned char _byte) -{ +void Mod::FileBase::writeByte(unsigned char _byte) { ByteVector data(1, _byte); writeBlock(data); } -void Mod::FileBase::writeU16L(unsigned short number) -{ +void Mod::FileBase::writeU16L(unsigned short number) { writeBlock(ByteVector::fromShort(number, false)); } -void Mod::FileBase::writeU32L(unsigned long number) -{ +void Mod::FileBase::writeU32L(unsigned long number) { writeBlock(ByteVector::fromUInt(number, false)); } -void Mod::FileBase::writeU16B(unsigned short number) -{ +void Mod::FileBase::writeU16B(unsigned short number) { writeBlock(ByteVector::fromShort(number, true)); } -void Mod::FileBase::writeU32B(unsigned long number) -{ +void Mod::FileBase::writeU32B(unsigned long number) { writeBlock(ByteVector::fromUInt(number, true)); } -bool Mod::FileBase::readByte(unsigned char &_byte) -{ +bool Mod::FileBase::readByte(unsigned char &_byte) { ByteVector data(readBlock(1)); - if(data.size() < 1) return false; + if (data.size() < 1) return false; _byte = data[0]; return true; } -bool Mod::FileBase::readU16L(unsigned short &number) -{ +bool Mod::FileBase::readU16L(unsigned short &number) { ByteVector data(readBlock(2)); - if(data.size() < 2) return false; + if (data.size() < 2) return false; number = data.toUShort(false); return true; } bool Mod::FileBase::readU32L(unsigned long &number) { ByteVector data(readBlock(4)); - if(data.size() < 4) return false; + if (data.size() < 4) return false; number = data.toUInt(false); return true; } -bool Mod::FileBase::readU16B(unsigned short &number) -{ +bool Mod::FileBase::readU16B(unsigned short &number) { ByteVector data(readBlock(2)); - if(data.size() < 2) return false; + if (data.size() < 2) return false; number = data.toUShort(true); return true; } bool Mod::FileBase::readU32B(unsigned long &number) { ByteVector data(readBlock(4)); - if(data.size() < 4) return false; + if (data.size() < 4) return false; number = data.toUInt(true); return true; } diff --git a/3rdparty/taglib/mod/modfilebase.h b/3rdparty/taglib/mod/modfilebase.h index 88cf21004..7ac600e37 100644 --- a/3rdparty/taglib/mod/modfilebase.h +++ b/3rdparty/taglib/mod/modfilebase.h @@ -37,32 +37,31 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace Mod { +namespace Mod { - class TAGLIB_EXPORT FileBase : public Strawberry_TagLib::TagLib::File - { - protected: - FileBase(FileName file); - FileBase(IOStream *stream); +class TAGLIB_EXPORT FileBase : public Strawberry_TagLib::TagLib::File { + protected: + FileBase(FileName file); + FileBase(IOStream *stream); - void writeString(const String &s, unsigned long size, char padding = 0); - void writeByte(unsigned char byte); - void writeU16L(unsigned short number); - void writeU32L(unsigned long number); - void writeU16B(unsigned short number); - void writeU32B(unsigned long number); + void writeString(const String &s, unsigned long size, char padding = 0); + void writeByte(unsigned char byte); + void writeU16L(unsigned short number); + void writeU32L(unsigned long number); + void writeU16B(unsigned short number); + void writeU32B(unsigned long number); - bool readString(String &s, unsigned long size); - bool readByte(unsigned char &byte); - bool readU16L(unsigned short &number); - bool readU32L(unsigned long &number); - bool readU16B(unsigned short &number); - bool readU32B(unsigned long &number); - }; + bool readString(String &s, unsigned long size); + bool readByte(unsigned char &byte); + bool readU16L(unsigned short &number); + bool readU32L(unsigned long &number); + bool readU16B(unsigned short &number); + bool readU32B(unsigned long &number); +}; - } +} // namespace Mod -} -} +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mod/modfileprivate.h b/3rdparty/taglib/mod/modfileprivate.h index 781db74c9..d21916537 100644 --- a/3rdparty/taglib/mod/modfileprivate.h +++ b/3rdparty/taglib/mod/modfileprivate.h @@ -24,44 +24,43 @@ // some helper-macros only used internally by (s3m|it|xm)file.cpp #define READ_ASSERT(cond) \ - if(!(cond)) \ - { \ - setValid(false); \ - return; \ + if (!(cond)) { \ + setValid(false); \ + return; \ } -#define READ(setter,type,read) \ - { \ - type number; \ - READ_ASSERT(read(number)); \ - setter(number); \ +#define READ(setter, type, read) \ + { \ + type number; \ + READ_ASSERT(read(number)); \ + setter(number); \ } -#define READ_BYTE(setter) READ(setter,unsigned char,readByte) -#define READ_U16L(setter) READ(setter,unsigned short,readU16L) -#define READ_U32L(setter) READ(setter,unsigned long,readU32L) -#define READ_U16B(setter) READ(setter,unsigned short,readU16B) -#define READ_U32B(setter) READ(setter,unsigned long,readU32B) +#define READ_BYTE(setter) READ(setter, unsigned char, readByte) +#define READ_U16L(setter) READ(setter, unsigned short, readU16L) +#define READ_U32L(setter) READ(setter, unsigned long, readU32L) +#define READ_U16B(setter) READ(setter, unsigned short, readU16B) +#define READ_U32B(setter) READ(setter, unsigned long, readU32B) -#define READ_STRING(setter,size) \ - { \ - String s; \ +#define READ_STRING(setter, size) \ + { \ + String s; \ READ_ASSERT(readString(s, size)); \ - setter(s); \ + setter(s); \ } -#define READ_AS(type,name,read) \ - type name = 0; \ +#define READ_AS(type, name, read) \ + type name = 0; \ READ_ASSERT(read(name)); -#define READ_BYTE_AS(name) READ_AS(unsigned char,name,readByte) -#define READ_U16L_AS(name) READ_AS(unsigned short,name,readU16L) -#define READ_U32L_AS(name) READ_AS(unsigned long,name,readU32L) -#define READ_U16B_AS(name) READ_AS(unsigned short,name,readU16B) -#define READ_U32B_AS(name) READ_AS(unsigned long,name,readU32B) +#define READ_BYTE_AS(name) READ_AS(unsigned char, name, readByte) +#define READ_U16L_AS(name) READ_AS(unsigned short, name, readU16L) +#define READ_U32L_AS(name) READ_AS(unsigned long, name, readU32L) +#define READ_U16B_AS(name) READ_AS(unsigned short, name, readU16B) +#define READ_U32B_AS(name) READ_AS(unsigned long, name, readU32B) -#define READ_STRING_AS(name,size) \ - String name; \ +#define READ_STRING_AS(name, size) \ + String name; \ READ_ASSERT(readString(name, size)); #endif diff --git a/3rdparty/taglib/mod/modproperties.cpp b/3rdparty/taglib/mod/modproperties.cpp index 756d91275..c727aff84 100644 --- a/3rdparty/taglib/mod/modproperties.cpp +++ b/3rdparty/taglib/mod/modproperties.cpp @@ -29,83 +29,66 @@ using namespace Strawberry_TagLib::TagLib; using namespace Mod; -class Mod::Properties::PropertiesPrivate -{ -public: - PropertiesPrivate() : - channels(0), - instrumentCount(0), - lengthInPatterns(0) - { +class Mod::Properties::PropertiesPrivate { + public: + PropertiesPrivate() : channels(0), + instrumentCount(0), + lengthInPatterns(0) { } - int channels; - unsigned int instrumentCount; + int channels; + unsigned int instrumentCount; unsigned char lengthInPatterns; }; -Mod::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) : - AudioProperties(propertiesStyle), - d(new PropertiesPrivate()) -{ +Mod::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) : AudioProperties(propertiesStyle), + d(new PropertiesPrivate()) { } -Mod::Properties::~Properties() -{ +Mod::Properties::~Properties() { delete d; } -int Mod::Properties::length() const -{ +int Mod::Properties::length() const { return 0; } -int Mod::Properties::lengthInSeconds() const -{ +int Mod::Properties::lengthInSeconds() const { return 0; } -int Mod::Properties::lengthInMilliseconds() const -{ +int Mod::Properties::lengthInMilliseconds() const { return 0; } -int Mod::Properties::bitrate() const -{ +int Mod::Properties::bitrate() const { return 0; } -int Mod::Properties::sampleRate() const -{ +int Mod::Properties::sampleRate() const { return 0; } -int Mod::Properties::channels() const -{ +int Mod::Properties::channels() const { return d->channels; } -unsigned int Mod::Properties::instrumentCount() const -{ +unsigned int Mod::Properties::instrumentCount() const { return d->instrumentCount; } -unsigned char Mod::Properties::lengthInPatterns() const -{ +unsigned char Mod::Properties::lengthInPatterns() const { return d->lengthInPatterns; } -void Mod::Properties::setChannels(int channels) -{ +void Mod::Properties::setChannels(int channels) { d->channels = channels; } -void Mod::Properties::setInstrumentCount(unsigned int instrumentCount) -{ +void Mod::Properties::setInstrumentCount(unsigned int instrumentCount) { d->instrumentCount = instrumentCount; } -void Mod::Properties::setLengthInPatterns(unsigned char lengthInPatterns) -{ +void Mod::Properties::setLengthInPatterns(unsigned char lengthInPatterns) { d->lengthInPatterns = lengthInPatterns; } diff --git a/3rdparty/taglib/mod/modproperties.h b/3rdparty/taglib/mod/modproperties.h index 0ed2592ec..370c4a454 100644 --- a/3rdparty/taglib/mod/modproperties.h +++ b/3rdparty/taglib/mod/modproperties.h @@ -32,42 +32,41 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace Mod { +namespace Mod { - class TAGLIB_EXPORT Properties : public AudioProperties - { - public: - Properties(AudioProperties::ReadStyle propertiesStyle); - virtual ~Properties(); +class TAGLIB_EXPORT Properties : public AudioProperties { + public: + Properties(AudioProperties::ReadStyle propertiesStyle); + virtual ~Properties(); - int length() const; - int lengthInSeconds() const; - int lengthInMilliseconds() const; - int bitrate() const; - int sampleRate() const; - int channels() const; + int length() const; + int lengthInSeconds() const; + int lengthInMilliseconds() const; + int bitrate() const; + int sampleRate() const; + int channels() const; - unsigned int instrumentCount() const; - unsigned char lengthInPatterns() const; + unsigned int instrumentCount() const; + unsigned char lengthInPatterns() const; - void setChannels(int channels); + void setChannels(int channels); - void setInstrumentCount(unsigned int sampleCount); - void setLengthInPatterns(unsigned char lengthInPatterns); + void setInstrumentCount(unsigned int sampleCount); + void setLengthInPatterns(unsigned char lengthInPatterns); - private: - friend class File; + private: + friend class File; - Properties(const Properties&); - Properties &operator=(const Properties&); + Properties(const Properties &); + Properties &operator=(const Properties &); - class PropertiesPrivate; - PropertiesPrivate *d; - }; + class PropertiesPrivate; + PropertiesPrivate *d; +}; - } +} // namespace Mod -} -} +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mod/modtag.cpp b/3rdparty/taglib/mod/modtag.cpp index 320cabcbf..710fed387 100644 --- a/3rdparty/taglib/mod/modtag.cpp +++ b/3rdparty/taglib/mod/modtag.cpp @@ -31,11 +31,9 @@ using namespace Strawberry_TagLib::TagLib; using namespace Mod; -class Mod::Tag::TagPrivate -{ -public: - TagPrivate() - { +class Mod::Tag::TagPrivate { + public: + TagPrivate() { } String title; @@ -43,132 +41,114 @@ public: String trackerName; }; -Mod::Tag::Tag() : - Strawberry_TagLib::TagLib::Tag(), - d(new TagPrivate()) -{ +Mod::Tag::Tag() : Strawberry_TagLib::TagLib::Tag(), + d(new TagPrivate()) { } -Mod::Tag::~Tag() -{ +Mod::Tag::~Tag() { delete d; } -String Mod::Tag::title() const -{ +String Mod::Tag::title() const { return d->title; } -String Mod::Tag::artist() const -{ +String Mod::Tag::artist() const { return String(); } -String Mod::Tag::album() const -{ +String Mod::Tag::album() const { return String(); } -String Mod::Tag::comment() const -{ +String Mod::Tag::comment() const { return d->comment; } -String Mod::Tag::genre() const -{ +String Mod::Tag::genre() const { return String(); } -unsigned int Mod::Tag::year() const -{ +unsigned int Mod::Tag::year() const { return 0; } -unsigned int Mod::Tag::track() const -{ +unsigned int Mod::Tag::track() const { return 0; } -String Mod::Tag::trackerName() const -{ +String Mod::Tag::trackerName() const { return d->trackerName; } -void Mod::Tag::setTitle(const String &title) -{ +void Mod::Tag::setTitle(const String &title) { d->title = title; } -void Mod::Tag::setArtist(const String &) -{ +void Mod::Tag::setArtist(const String &) { } -void Mod::Tag::setAlbum(const String &) -{ +void Mod::Tag::setAlbum(const String &) { } -void Mod::Tag::setComment(const String &comment) -{ +void Mod::Tag::setComment(const String &comment) { d->comment = comment; } -void Mod::Tag::setGenre(const String &) -{ +void Mod::Tag::setGenre(const String &) { } -void Mod::Tag::setYear(unsigned int) -{ +void Mod::Tag::setYear(unsigned int) { } -void Mod::Tag::setTrack(unsigned int) -{ +void Mod::Tag::setTrack(unsigned int) { } -void Mod::Tag::setTrackerName(const String &trackerName) -{ +void Mod::Tag::setTrackerName(const String &trackerName) { d->trackerName = trackerName; } -PropertyMap Mod::Tag::properties() const -{ +PropertyMap Mod::Tag::properties() const { PropertyMap properties; properties["TITLE"] = d->title; properties["COMMENT"] = d->comment; - if(!(d->trackerName.isEmpty())) + if (!(d->trackerName.isEmpty())) properties["TRACKERNAME"] = d->trackerName; return properties; } -PropertyMap Mod::Tag::setProperties(const PropertyMap &origProps) -{ +PropertyMap Mod::Tag::setProperties(const PropertyMap &origProps) { PropertyMap properties(origProps); properties.removeEmpty(); StringList oneValueSet; - if(properties.contains("TITLE")) { + if (properties.contains("TITLE")) { d->title = properties["TITLE"].front(); oneValueSet.append("TITLE"); - } else + } + else d->title.clear(); - if(properties.contains("COMMENT")) { + if (properties.contains("COMMENT")) { d->comment = properties["COMMENT"].front(); oneValueSet.append("COMMENT"); - } else + } + else d->comment.clear(); - if(properties.contains("TRACKERNAME")) { + if (properties.contains("TRACKERNAME")) { d->trackerName = properties["TRACKERNAME"].front(); oneValueSet.append("TRACKERNAME"); - } else + } + else d->trackerName.clear(); // for each tag that has been set above, remove the first entry in the corresponding // value list. The others will be returned as unsupported by this format. - for(StringList::ConstIterator it = oneValueSet.begin(); it != oneValueSet.end(); ++it) { - if(properties[*it].size() == 1) + for (StringList::ConstIterator it = oneValueSet.begin(); it != oneValueSet.end(); ++it) { + if (properties[*it].size() == 1) properties.erase(*it); else - properties[*it].erase( properties[*it].begin() ); + properties[*it].erase(properties[*it].begin()); } return properties; } diff --git a/3rdparty/taglib/mod/modtag.h b/3rdparty/taglib/mod/modtag.h index b2a761d18..9fffec77f 100644 --- a/3rdparty/taglib/mod/modtag.h +++ b/3rdparty/taglib/mod/modtag.h @@ -31,9 +31,9 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace Mod { +namespace Mod { - /*! +/*! * Tags for module files (Mod, S3M, IT, XM). * * Note that only the \a title is supported as such by most @@ -45,60 +45,59 @@ namespace TagLib { * but it is common practice to abuse instrument/sample/pattern * names as multiline comments. TagLib does so as well. */ - class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag - { - public: - Tag(); - virtual ~Tag(); +class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag { + public: + Tag(); + virtual ~Tag(); - /*! + /*! * Returns the track name; if no track name is present in the tag * String::null will be returned. */ - virtual String title() const; + virtual String title() const; - /*! + /*! * Not supported by module files. Therefore always returns String::null. */ - virtual String artist() const; + virtual String artist() const; - /*! + /*! * Not supported by module files. Therefore always returns String::null. */ - virtual String album() const; + virtual String album() const; - /*! + /*! * Returns the track comment derived from the instrument/sample/pattern * names; if no comment is present in the tag String::null will be * returned. */ - virtual String comment() const; + virtual String comment() const; - /*! + /*! * Not supported by module files. Therefore always returns String::null. */ - virtual String genre() const; + virtual String genre() const; - /*! + /*! * Not supported by module files. Therefore always returns 0. */ - virtual unsigned int year() const; + virtual unsigned int year() const; - /*! + /*! * Not supported by module files. Therefore always returns 0. */ - virtual unsigned int track() const; + virtual unsigned int track() const; - /*! + /*! * Returns the name of the tracker used to create/edit the module file. * Only XM files store this tag to the file as such, for other formats * (Mod, S3M, IT) this is derived from the file type or the flavour of * the file type. Therefore only XM files might have an empty * (String::null) tracker name. */ - String trackerName() const; + String trackerName() const; - /*! + /*! * Sets the title to \a title. If \a title is String::null then this * value will be cleared. * @@ -106,19 +105,19 @@ namespace TagLib { * Mod 20 characters, S3M 27 characters, IT 25 characters and XM 20 * characters. */ - virtual void setTitle(const String &title); + virtual void setTitle(const String &title); - /*! + /*! * Not supported by module files and therefore ignored. */ - virtual void setArtist(const String &artist); + virtual void setArtist(const String &artist); - /*! + /*! * Not supported by module files and therefore ignored. */ - virtual void setAlbum(const String &album); + virtual void setAlbum(const String &album); - /*! + /*! * Sets the comment to \a comment. If \a comment is String::null then * this value will be cleared. * @@ -135,24 +134,24 @@ namespace TagLib { * Mod 22 characters, S3M 27 characters, IT 25 characters and XM 22 * characters. */ - virtual void setComment(const String &comment); + virtual void setComment(const String &comment); - /*! + /*! * Not supported by module files and therefore ignored. */ - virtual void setGenre(const String &genre); + virtual void setGenre(const String &genre); - /*! + /*! * Not supported by module files and therefore ignored. */ - virtual void setYear(unsigned int year); + virtual void setYear(unsigned int year); - /*! + /*! * Not supported by module files and therefore ignored. */ - virtual void setTrack(unsigned int track); + virtual void setTrack(unsigned int track); - /*! + /*! * Sets the tracker name to \a trackerName. If \a trackerName is * String::null then this value will be cleared. * @@ -162,15 +161,15 @@ namespace TagLib { * The length of this tag is limited to 20 characters (1 character * = 1 byte). */ - void setTrackerName(const String &trackerName); + void setTrackerName(const String &trackerName); - /*! + /*! * Implements the unified property interface -- export function. * Since the module tag is very limited, the exported map is as well. */ - PropertyMap properties() const; + PropertyMap properties() const; - /*! + /*! * Implements the unified property interface -- import function. * Because of the limitations of the module file tag, any tags besides * COMMENT, TITLE and, if it is an XM file, TRACKERNAME, will be @@ -178,19 +177,19 @@ namespace TagLib { * all but the first will be contained in the returned map of unsupported * properties. */ - PropertyMap setProperties(const PropertyMap &); + PropertyMap setProperties(const PropertyMap &); - private: - Tag(const Tag &); - Tag &operator=(const Tag &); + private: + Tag(const Tag &); + Tag &operator=(const Tag &); - class TagPrivate; - TagPrivate *d; - }; + class TagPrivate; + TagPrivate *d; +}; - } +} // namespace Mod -} -} +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mp4/mp4atom.cpp b/3rdparty/taglib/mp4/mp4atom.cpp index 645e2cdef..a90e16ab5 100644 --- a/3rdparty/taglib/mp4/mp4atom.cpp +++ b/3rdparty/taglib/mp4/mp4atom.cpp @@ -32,18 +32,17 @@ using namespace Strawberry_TagLib::TagLib; const char *MP4::Atom::containers[11] = { - "moov", "udta", "mdia", "meta", "ilst", - "stbl", "minf", "moof", "traf", "trak", - "stsd" + "moov", "udta", "mdia", "meta", "ilst", + "stbl", "minf", "moof", "traf", "trak", + "stsd" }; -MP4::Atom::Atom(File *file) -{ +MP4::Atom::Atom(File *file) { children.setAutoDelete(true); offset = file->tell(); ByteVector header = file->readBlock(8); - if(header.size() != 8) { + if (header.size() != 8) { // The atom header must be 8 bytes long, otherwise there is either // trailing garbage or the file is truncated debug("MP4: Couldn't read 8 bytes of data for atom header"); @@ -54,14 +53,14 @@ MP4::Atom::Atom(File *file) length = header.toUInt(); - if(length == 0) { + if (length == 0) { // The last atom which extends to the end of the file. length = file->length() - offset; } - else if(length == 1) { + else if (length == 1) { // The atom has a 64-bit length. const long long longLength = file->readBlock(8).toLongLong(); - if(longLength <= LONG_MAX) { + if (longLength <= LONG_MAX) { // The actual length fits in long. That's always the case if long is 64-bit. length = static_cast(longLength); } @@ -73,7 +72,7 @@ MP4::Atom::Atom(File *file) } } - if(length < 8) { + if (length < 8) { debug("MP4: Invalid atom size"); length = 0; file->seek(0, File::End); @@ -82,18 +81,18 @@ MP4::Atom::Atom(File *file) name = header.mid(4, 4); - for(int i = 0; i < numContainers; i++) { - if(name == containers[i]) { - if(name == "meta") { + for (int i = 0; i < numContainers; i++) { + if (name == containers[i]) { + if (name == "meta") { file->seek(4, File::Current); } - else if(name == "stsd") { + else if (name == "stsd") { file->seek(8, File::Current); } - while(file->tell() < offset + length) { + while (file->tell() < offset + length) { MP4::Atom *child = new MP4::Atom(file); children.append(child); - if(child->length == 0) + if (child->length == 0) return; } return; @@ -103,18 +102,16 @@ MP4::Atom::Atom(File *file) file->seek(offset + length); } -MP4::Atom::~Atom() -{ +MP4::Atom::~Atom() { } MP4::Atom * -MP4::Atom::find(const char *name1, const char *name2, const char *name3, const char *name4) -{ - if(name1 == 0) { +MP4::Atom::find(const char *name1, const char *name2, const char *name3, const char *name4) { + if (name1 == 0) { return this; } - for(AtomList::ConstIterator it = children.begin(); it != children.end(); ++it) { - if((*it)->name == name1) { + for (AtomList::ConstIterator it = children.begin(); it != children.end(); ++it) { + if ((*it)->name == name1) { return (*it)->find(name2, name3, name4); } } @@ -122,43 +119,39 @@ MP4::Atom::find(const char *name1, const char *name2, const char *name3, const c } MP4::AtomList -MP4::Atom::findall(const char *_name, bool recursive) -{ +MP4::Atom::findall(const char *_name, bool recursive) { MP4::AtomList result; - for(AtomList::ConstIterator it = children.begin(); it != children.end(); ++it) { - if((*it)->name == _name) { + for (AtomList::ConstIterator it = children.begin(); it != children.end(); ++it) { + if ((*it)->name == _name) { result.append(*it); } - if(recursive) { + if (recursive) { result.append((*it)->findall(_name, recursive)); } } return result; } -bool -MP4::Atom::path(MP4::AtomList &path, const char *name1, const char *name2, const char *name3) -{ +bool MP4::Atom::path(MP4::AtomList &path, const char *name1, const char *name2, const char *name3) { path.append(this); - if(name1 == 0) { + if (name1 == 0) { return true; } - for(AtomList::ConstIterator it = children.begin(); it != children.end(); ++it) { - if((*it)->name == name1) { + for (AtomList::ConstIterator it = children.begin(); it != children.end(); ++it) { + if ((*it)->name == name1) { return (*it)->path(path, name2, name3); } } return false; } -MP4::Atoms::Atoms(File *file) -{ +MP4::Atoms::Atoms(File *file) { atoms.setAutoDelete(true); file->seek(0, File::End); long end = file->tell(); file->seek(0); - while(file->tell() + 8 <= end) { + while (file->tell() + 8 <= end) { MP4::Atom *atom = new MP4::Atom(file); atoms.append(atom); if (atom->length == 0) @@ -166,15 +159,13 @@ MP4::Atoms::Atoms(File *file) } } -MP4::Atoms::~Atoms() -{ +MP4::Atoms::~Atoms() { } MP4::Atom * -MP4::Atoms::find(const char *name1, const char *name2, const char *name3, const char *name4) -{ - for(AtomList::ConstIterator it = atoms.begin(); it != atoms.end(); ++it) { - if((*it)->name == name1) { +MP4::Atoms::find(const char *name1, const char *name2, const char *name3, const char *name4) { + for (AtomList::ConstIterator it = atoms.begin(); it != atoms.end(); ++it) { + if ((*it)->name == name1) { return (*it)->find(name2, name3, name4); } } @@ -182,12 +173,11 @@ MP4::Atoms::find(const char *name1, const char *name2, const char *name3, const } MP4::AtomList -MP4::Atoms::path(const char *name1, const char *name2, const char *name3, const char *name4) -{ +MP4::Atoms::path(const char *name1, const char *name2, const char *name3, const char *name4) { MP4::AtomList path; - for(AtomList::ConstIterator it = atoms.begin(); it != atoms.end(); ++it) { - if((*it)->name == name1) { - if(!(*it)->path(path, name2, name3, name4)) { + for (AtomList::ConstIterator it = atoms.begin(); it != atoms.end(); ++it) { + if ((*it)->name == name1) { + if (!(*it)->path(path, name2, name3, name4)) { path.clear(); } return path; diff --git a/3rdparty/taglib/mp4/mp4atom.h b/3rdparty/taglib/mp4/mp4atom.h index 13693a125..c580baceb 100644 --- a/3rdparty/taglib/mp4/mp4atom.h +++ b/3rdparty/taglib/mp4/mp4atom.h @@ -27,87 +27,85 @@ #ifndef DO_NOT_DOCUMENT -#ifndef TAGLIB_MP4ATOM_H -#define TAGLIB_MP4ATOM_H +# ifndef TAGLIB_MP4ATOM_H +# define TAGLIB_MP4ATOM_H -#include "tfile.h" -#include "tlist.h" +# include "tfile.h" +# include "tlist.h" namespace Strawberry_TagLib { namespace TagLib { - namespace MP4 { +namespace MP4 { - class Atom; - typedef Strawberry_TagLib::TagLib::List AtomList; +class Atom; +typedef Strawberry_TagLib::TagLib::List AtomList; - enum AtomDataType - { - TypeImplicit = 0, // for use with tags for which no type needs to be indicated because only one type is allowed - TypeUTF8 = 1, // without any count or null terminator - TypeUTF16 = 2, // also known as UTF-16BE - TypeSJIS = 3, // deprecated unless it is needed for special Japanese characters - TypeHTML = 6, // the HTML file header specifies which HTML version - TypeXML = 7, // the XML header must identify the DTD or schemas - TypeUUID = 8, // also known as GUID; stored as 16 bytes in binary (valid as an ID) - TypeISRC = 9, // stored as UTF-8 text (valid as an ID) - TypeMI3P = 10, // stored as UTF-8 text (valid as an ID) - TypeGIF = 12, // (deprecated) a GIF image - TypeJPEG = 13, // a JPEG image - TypePNG = 14, // a PNG image - TypeURL = 15, // absolute, in UTF-8 characters - TypeDuration = 16, // in milliseconds, 32-bit integer - TypeDateTime = 17, // in UTC, counting seconds since midnight, January 1, 1904; 32 or 64-bits - TypeGenred = 18, // a list of enumerated values - TypeInteger = 21, // a signed big-endian integer with length one of { 1,2,3,4,8 } bytes - TypeRIAAPA = 24, // RIAA parental advisory; { -1=no, 1=yes, 0=unspecified }, 8-bit integer - TypeUPC = 25, // Universal Product Code, in text UTF-8 format (valid as an ID) - TypeBMP = 27, // Windows bitmap image - TypeUndefined = 255 // undefined - }; +enum AtomDataType { + TypeImplicit = 0, // for use with tags for which no type needs to be indicated because only one type is allowed + TypeUTF8 = 1, // without any count or null terminator + TypeUTF16 = 2, // also known as UTF-16BE + TypeSJIS = 3, // deprecated unless it is needed for special Japanese characters + TypeHTML = 6, // the HTML file header specifies which HTML version + TypeXML = 7, // the XML header must identify the DTD or schemas + TypeUUID = 8, // also known as GUID; stored as 16 bytes in binary (valid as an ID) + TypeISRC = 9, // stored as UTF-8 text (valid as an ID) + TypeMI3P = 10, // stored as UTF-8 text (valid as an ID) + TypeGIF = 12, // (deprecated) a GIF image + TypeJPEG = 13, // a JPEG image + TypePNG = 14, // a PNG image + TypeURL = 15, // absolute, in UTF-8 characters + TypeDuration = 16, // in milliseconds, 32-bit integer + TypeDateTime = 17, // in UTC, counting seconds since midnight, January 1, 1904; 32 or 64-bits + TypeGenred = 18, // a list of enumerated values + TypeInteger = 21, // a signed big-endian integer with length one of { 1,2,3,4,8 } bytes + TypeRIAAPA = 24, // RIAA parental advisory; { -1=no, 1=yes, 0=unspecified }, 8-bit integer + TypeUPC = 25, // Universal Product Code, in text UTF-8 format (valid as an ID) + TypeBMP = 27, // Windows bitmap image + TypeUndefined = 255 // undefined +}; - struct AtomData { - AtomData(AtomDataType _type, ByteVector _data) : type(_type), locale(0), data(_data) {} - AtomDataType type; - int locale; - ByteVector data; - }; +struct AtomData { + AtomData(AtomDataType _type, ByteVector _data) : type(_type), locale(0), data(_data) {} + AtomDataType type; + int locale; + ByteVector data; +}; - typedef Strawberry_TagLib::TagLib::List AtomDataList; +typedef Strawberry_TagLib::TagLib::List AtomDataList; - class Atom - { - public: - Atom(File *file); - ~Atom(); - Atom *find(const char *name1, const char *name2 = 0, const char *name3 = 0, const char *name4 = 0); - bool path(AtomList &path, const char *name1, const char *name2 = 0, const char *name3 = 0); - AtomList findall(const char *name, bool recursive = false); - long offset; - long length; - Strawberry_TagLib::TagLib::ByteVector name; - AtomList children; - private: - static const int numContainers = 11; - static const char *containers[11]; - }; +class Atom { + public: + Atom(File *file); + ~Atom(); + Atom *find(const char *name1, const char *name2 = 0, const char *name3 = 0, const char *name4 = 0); + bool path(AtomList &path, const char *name1, const char *name2 = 0, const char *name3 = 0); + AtomList findall(const char *name, bool recursive = false); + long offset; + long length; + Strawberry_TagLib::TagLib::ByteVector name; + AtomList children; - //! Root-level atoms - class Atoms - { - public: - Atoms(File *file); - ~Atoms(); - Atom *find(const char *name1, const char *name2 = 0, const char *name3 = 0, const char *name4 = 0); - AtomList path(const char *name1, const char *name2 = 0, const char *name3 = 0, const char *name4 = 0); - AtomList atoms; - }; + private: + static const int numContainers = 11; + static const char *containers[11]; +}; - } +//! Root-level atoms +class Atoms { + public: + Atoms(File *file); + ~Atoms(); + Atom *find(const char *name1, const char *name2 = 0, const char *name3 = 0, const char *name4 = 0); + AtomList path(const char *name1, const char *name2 = 0, const char *name3 = 0, const char *name4 = 0); + AtomList atoms; +}; -} -} - -#endif +} // namespace MP4 + +} // namespace TagLib +} // namespace Strawberry_TagLib + +# endif #endif diff --git a/3rdparty/taglib/mp4/mp4coverart.cpp b/3rdparty/taglib/mp4/mp4coverart.cpp index 48adce851..7dc2e69f6 100644 --- a/3rdparty/taglib/mp4/mp4coverart.cpp +++ b/3rdparty/taglib/mp4/mp4coverart.cpp @@ -30,12 +30,10 @@ using namespace Strawberry_TagLib::TagLib; -class MP4::CoverArt::CoverArtPrivate : public RefCounter -{ -public: - CoverArtPrivate() : - RefCounter(), - format(MP4::CoverArt::JPEG) {} +class MP4::CoverArt::CoverArtPrivate : public RefCounter { + public: + CoverArtPrivate() : RefCounter(), + format(MP4::CoverArt::JPEG) {} Format format; ByteVector data; @@ -45,49 +43,39 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -MP4::CoverArt::CoverArt(Format format, const ByteVector &data) : - d(new CoverArtPrivate()) -{ +MP4::CoverArt::CoverArt(Format format, const ByteVector &data) : d(new CoverArtPrivate()) { d->format = format; d->data = data; } -MP4::CoverArt::CoverArt(const CoverArt &item) : - d(item.d) -{ +MP4::CoverArt::CoverArt(const CoverArt &item) : d(item.d) { d->ref(); } MP4::CoverArt & -MP4::CoverArt::operator=(const CoverArt &item) -{ +MP4::CoverArt::operator=(const CoverArt &item) { CoverArt(item).swap(*this); return *this; } -void -MP4::CoverArt::swap(CoverArt &item) -{ +void MP4::CoverArt::swap(CoverArt &item) { using std::swap; swap(d, item.d); } -MP4::CoverArt::~CoverArt() -{ - if(d->deref()) { +MP4::CoverArt::~CoverArt() { + if (d->deref()) { delete d; } } MP4::CoverArt::Format -MP4::CoverArt::format() const -{ +MP4::CoverArt::format() const { return d->format; } ByteVector -MP4::CoverArt::data() const -{ +MP4::CoverArt::data() const { return d->data; } diff --git a/3rdparty/taglib/mp4/mp4coverart.h b/3rdparty/taglib/mp4/mp4coverart.h index 6bba79774..1100c1b01 100644 --- a/3rdparty/taglib/mp4/mp4coverart.h +++ b/3rdparty/taglib/mp4/mp4coverart.h @@ -34,53 +34,52 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace MP4 { +namespace MP4 { - class TAGLIB_EXPORT CoverArt - { - public: - /*! +class TAGLIB_EXPORT CoverArt { + public: + /*! * This describes the image type. */ - enum Format { - JPEG = TypeJPEG, - PNG = TypePNG, - BMP = TypeBMP, - GIF = TypeGIF, - Unknown = TypeImplicit, - }; + enum Format { + JPEG = TypeJPEG, + PNG = TypePNG, + BMP = TypeBMP, + GIF = TypeGIF, + Unknown = TypeImplicit, + }; - CoverArt(Format format, const ByteVector &data); - ~CoverArt(); + CoverArt(Format format, const ByteVector &data); + ~CoverArt(); - CoverArt(const CoverArt &item); + CoverArt(const CoverArt &item); - /*! + /*! * Copies the contents of \a item into this CoverArt. */ - CoverArt &operator=(const CoverArt &item); + CoverArt &operator=(const CoverArt &item); - /*! + /*! * Exchanges the content of the CoverArt by the content of \a item. */ - void swap(CoverArt &item); + void swap(CoverArt &item); - //! Format of the image - Format format() const; + //! Format of the image + Format format() const; - //! The image data - ByteVector data() const; + //! The image data + ByteVector data() const; - private: - class CoverArtPrivate; - CoverArtPrivate *d; - }; + private: + class CoverArtPrivate; + CoverArtPrivate *d; +}; - typedef List CoverArtList; +typedef List CoverArtList; - } +} // namespace MP4 -} -} +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mp4/mp4file.cpp b/3rdparty/taglib/mp4/mp4file.cpp index 691e52ead..31a59c68c 100644 --- a/3rdparty/taglib/mp4/mp4file.cpp +++ b/3rdparty/taglib/mp4/mp4file.cpp @@ -34,40 +34,35 @@ using namespace Strawberry_TagLib::TagLib; -namespace -{ - bool checkValid(const MP4::AtomList &list) - { - for(MP4::AtomList::ConstIterator it = list.begin(); it != list.end(); ++it) { +namespace { +bool checkValid(const MP4::AtomList &list) { + for (MP4::AtomList::ConstIterator it = list.begin(); it != list.end(); ++it) { - if((*it)->length == 0) - return false; + if ((*it)->length == 0) + return false; - if(!checkValid((*it)->children)) - return false; - } - - return true; + if (!checkValid((*it)->children)) + return false; } + + return true; } +} // namespace -class MP4::File::FilePrivate -{ -public: - FilePrivate() : - tag(0), - atoms(0), - properties(0) {} +class MP4::File::FilePrivate { + public: + FilePrivate() : tag(0), + atoms(0), + properties(0) {} - ~FilePrivate() - { + ~FilePrivate() { delete atoms; delete tag; delete properties; } - MP4::Tag *tag; - MP4::Atoms *atoms; + MP4::Tag *tag; + MP4::Atoms *atoms; MP4::Properties *properties; }; @@ -75,8 +70,7 @@ public: // static members //////////////////////////////////////////////////////////////////////////////// -bool MP4::File::isSupported(IOStream *stream) -{ +bool MP4::File::isSupported(IOStream *stream) { // An MP4 file has to have an "ftyp" box first. const ByteVector id = Utils::readHeader(stream, 8, false); @@ -87,87 +81,73 @@ bool MP4::File::isSupported(IOStream *stream) // public members //////////////////////////////////////////////////////////////////////////////// -MP4::File::File(FileName file, bool readProperties, AudioProperties::ReadStyle) : - Strawberry_TagLib::TagLib::File(file), - d(new FilePrivate()) -{ - if(isOpen()) +MP4::File::File(FileName file, bool readProperties, AudioProperties::ReadStyle) : Strawberry_TagLib::TagLib::File(file), + d(new FilePrivate()) { + if (isOpen()) read(readProperties); } -MP4::File::File(IOStream *stream, bool readProperties, AudioProperties::ReadStyle) : - Strawberry_TagLib::TagLib::File(stream), - d(new FilePrivate()) -{ - if(isOpen()) +MP4::File::File(IOStream *stream, bool readProperties, AudioProperties::ReadStyle) : Strawberry_TagLib::TagLib::File(stream), + d(new FilePrivate()) { + if (isOpen()) read(readProperties); } -MP4::File::~File() -{ +MP4::File::~File() { delete d; } MP4::Tag * -MP4::File::tag() const -{ +MP4::File::tag() const { return d->tag; } -PropertyMap MP4::File::properties() const -{ +PropertyMap MP4::File::properties() const { return d->tag->properties(); } -void MP4::File::removeUnsupportedProperties(const StringList &properties) -{ +void MP4::File::removeUnsupportedProperties(const StringList &properties) { d->tag->removeUnsupportedProperties(properties); } -PropertyMap MP4::File::setProperties(const PropertyMap &properties) -{ +PropertyMap MP4::File::setProperties(const PropertyMap &properties) { return d->tag->setProperties(properties); } MP4::Properties * -MP4::File::audioProperties() const -{ +MP4::File::audioProperties() const { return d->properties; } -void -MP4::File::read(bool readProperties) -{ - if(!isValid()) +void MP4::File::read(bool readProperties) { + if (!isValid()) return; d->atoms = new Atoms(this); - if(!checkValid(d->atoms->atoms)) { + if (!checkValid(d->atoms->atoms)) { setValid(false); return; } // must have a moov atom, otherwise consider it invalid - if(!d->atoms->find("moov")) { + if (!d->atoms->find("moov")) { setValid(false); return; } d->tag = new Tag(this, d->atoms); - if(readProperties) { + if (readProperties) { d->properties = new Properties(this, d->atoms); } } -bool -MP4::File::save() -{ - if(readOnly()) { +bool MP4::File::save() { + if (readOnly()) { debug("MP4::File::save() -- File is read only."); return false; } - if(!isValid()) { + if (!isValid()) { debug("MP4::File::save() -- Trying to save invalid file."); return false; } @@ -175,8 +155,6 @@ MP4::File::save() return d->tag->save(); } -bool -MP4::File::hasMP4Tag() const -{ +bool MP4::File::hasMP4Tag() const { return (d->atoms->find("moov", "udta", "meta", "ilst") != 0); } diff --git a/3rdparty/taglib/mp4/mp4file.h b/3rdparty/taglib/mp4/mp4file.h index 3ccfe3aef..b0d93ea6f 100644 --- a/3rdparty/taglib/mp4/mp4file.h +++ b/3rdparty/taglib/mp4/mp4file.h @@ -35,30 +35,29 @@ namespace Strawberry_TagLib { namespace TagLib { - //! An implementation of MP4 (AAC, ALAC, ...) metadata - namespace MP4 { +//! An implementation of MP4 (AAC, ALAC, ...) metadata +namespace MP4 { - class Atoms; +class Atoms; - /*! +/*! * This implements and provides an interface for MP4 files to the * TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing * the abstract TagLib::File API as well as providing some additional * information specific to MP4 files. */ - class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File - { - public: - /*! +class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File { + public: + /*! * Constructs an MP4 file from \a file. If \a readProperties is true the * file's audio properties will also be read. * * \note In the current implementation, \a propertiesStyle is ignored. */ - File(FileName file, bool readProperties = true, - Properties::ReadStyle audioPropertiesStyle = Properties::Average); + File(FileName file, bool readProperties = true, + Properties::ReadStyle audioPropertiesStyle = Properties::Average); - /*! + /*! * Constructs an MP4 file from \a stream. If \a readProperties is true the * file's audio properties will also be read. * @@ -67,15 +66,15 @@ namespace TagLib { * * \note In the current implementation, \a propertiesStyle is ignored. */ - File(IOStream *stream, bool readProperties = true, - Properties::ReadStyle audioPropertiesStyle = Properties::Average); + File(IOStream *stream, bool readProperties = true, + Properties::ReadStyle audioPropertiesStyle = Properties::Average); - /*! + /*! * Destroys this instance of the File. */ - virtual ~File(); + virtual ~File(); - /*! + /*! * Returns a pointer to the MP4 tag of the file. * * MP4::Tag implements the tag interface, so this serves as the @@ -85,61 +84,61 @@ namespace TagLib { * deleted by the user. It will be deleted when the file (object) is * destroyed. */ - Tag *tag() const; + Tag *tag() const; - /*! + /*! * Implements the unified property interface -- export function. */ - PropertyMap properties() const; + PropertyMap properties() const; - /*! + /*! * Removes unsupported properties. Forwards to the actual Tag's * removeUnsupportedProperties() function. */ - void removeUnsupportedProperties(const StringList &properties); + void removeUnsupportedProperties(const StringList &properties); - /*! + /*! * Implements the unified property interface -- import function. */ - PropertyMap setProperties(const PropertyMap &); + PropertyMap setProperties(const PropertyMap &); - /*! + /*! * Returns the MP4 audio properties for this file. */ - Properties *audioProperties() const; + Properties *audioProperties() const; - /*! + /*! * Save the file. * * This returns true if the save was successful. */ - bool save(); + bool save(); - /*! + /*! * Returns whether or not the file on disk actually has an MP4 tag, or the * file has a Metadata Item List (ilst) atom. */ - bool hasMP4Tag() const; + bool hasMP4Tag() const; - /*! + /*! * Returns whether or not the given \a stream can be opened as an ASF * file. * * \note This method is designed to do a quick check. The result may * not necessarily be correct. */ - static bool isSupported(IOStream *stream); + static bool isSupported(IOStream *stream); - private: - void read(bool readProperties); + private: + void read(bool readProperties); - class FilePrivate; - FilePrivate *d; - }; + class FilePrivate; + FilePrivate *d; +}; - } +} // namespace MP4 -} -} +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mp4/mp4item.cpp b/3rdparty/taglib/mp4/mp4item.cpp index 287780424..4427c6988 100644 --- a/3rdparty/taglib/mp4/mp4item.cpp +++ b/3rdparty/taglib/mp4/mp4item.cpp @@ -30,13 +30,11 @@ using namespace Strawberry_TagLib::TagLib; -class MP4::Item::ItemPrivate : public RefCounter -{ -public: - ItemPrivate() : - RefCounter(), - valid(true), - atomDataType(TypeUndefined) {} +class MP4::Item::ItemPrivate : public RefCounter { + public: + ItemPrivate() : RefCounter(), + valid(true), + atomDataType(TypeUndefined) {} bool valid; AtomDataType atomDataType; @@ -53,160 +51,119 @@ public: MP4::CoverArtList m_coverArtList; }; -MP4::Item::Item() : - d(new ItemPrivate()) -{ +MP4::Item::Item() : d(new ItemPrivate()) { d->valid = false; } -MP4::Item::Item(const Item &item) : - d(item.d) -{ +MP4::Item::Item(const Item &item) : d(item.d) { d->ref(); } MP4::Item & -MP4::Item::operator=(const Item &item) -{ +MP4::Item::operator=(const Item &item) { Item(item).swap(*this); return *this; } -void -MP4::Item::swap(Item &item) -{ +void MP4::Item::swap(Item &item) { using std::swap; swap(d, item.d); } -MP4::Item::~Item() -{ - if(d->deref()) +MP4::Item::~Item() { + if (d->deref()) delete d; } -MP4::Item::Item(bool value) : - d(new ItemPrivate()) -{ +MP4::Item::Item(bool value) : d(new ItemPrivate()) { d->m_bool = value; } -MP4::Item::Item(int value) : - d(new ItemPrivate()) -{ +MP4::Item::Item(int value) : d(new ItemPrivate()) { d->m_int = value; } -MP4::Item::Item(unsigned char value) : - d(new ItemPrivate()) -{ +MP4::Item::Item(unsigned char value) : d(new ItemPrivate()) { d->m_byte = value; } -MP4::Item::Item(unsigned int value) : - d(new ItemPrivate()) -{ +MP4::Item::Item(unsigned int value) : d(new ItemPrivate()) { d->m_uint = value; } -MP4::Item::Item(long long value) : - d(new ItemPrivate()) -{ +MP4::Item::Item(long long value) : d(new ItemPrivate()) { d->m_longlong = value; } -MP4::Item::Item(int value1, int value2) : - d(new ItemPrivate()) -{ +MP4::Item::Item(int value1, int value2) : d(new ItemPrivate()) { d->m_intPair.first = value1; d->m_intPair.second = value2; } -MP4::Item::Item(const ByteVectorList &value) : - d(new ItemPrivate()) -{ +MP4::Item::Item(const ByteVectorList &value) : d(new ItemPrivate()) { d->m_byteVectorList = value; } -MP4::Item::Item(const StringList &value) : - d(new ItemPrivate()) -{ +MP4::Item::Item(const StringList &value) : d(new ItemPrivate()) { d->m_stringList = value; } -MP4::Item::Item(const MP4::CoverArtList &value) : - d(new ItemPrivate()) -{ +MP4::Item::Item(const MP4::CoverArtList &value) : d(new ItemPrivate()) { d->m_coverArtList = value; } -void MP4::Item::setAtomDataType(MP4::AtomDataType type) -{ +void MP4::Item::setAtomDataType(MP4::AtomDataType type) { d->atomDataType = type; } -MP4::AtomDataType MP4::Item::atomDataType() const -{ +MP4::AtomDataType MP4::Item::atomDataType() const { return d->atomDataType; } -bool -MP4::Item::toBool() const -{ +bool MP4::Item::toBool() const { return d->m_bool; } -int -MP4::Item::toInt() const -{ +int MP4::Item::toInt() const { return d->m_int; } unsigned char -MP4::Item::toByte() const -{ +MP4::Item::toByte() const { return d->m_byte; } unsigned int -MP4::Item::toUInt() const -{ +MP4::Item::toUInt() const { return d->m_uint; } long long -MP4::Item::toLongLong() const -{ +MP4::Item::toLongLong() const { return d->m_longlong; } MP4::Item::IntPair -MP4::Item::toIntPair() const -{ +MP4::Item::toIntPair() const { return d->m_intPair; } StringList -MP4::Item::toStringList() const -{ +MP4::Item::toStringList() const { return d->m_stringList; } ByteVectorList -MP4::Item::toByteVectorList() const -{ +MP4::Item::toByteVectorList() const { return d->m_byteVectorList; } MP4::CoverArtList -MP4::Item::toCoverArtList() const -{ +MP4::Item::toCoverArtList() const { return d->m_coverArtList; } -bool -MP4::Item::isValid() const -{ +bool MP4::Item::isValid() const { return d->valid; } diff --git a/3rdparty/taglib/mp4/mp4item.h b/3rdparty/taglib/mp4/mp4item.h index fbdd95ae7..73fa40daf 100644 --- a/3rdparty/taglib/mp4/mp4item.h +++ b/3rdparty/taglib/mp4/mp4item.h @@ -33,63 +33,62 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace MP4 { +namespace MP4 { - class TAGLIB_EXPORT Item - { - public: - struct IntPair { - int first, second; - }; +class TAGLIB_EXPORT Item { + public: + struct IntPair { + int first, second; + }; - Item(); - Item(const Item &item); + Item(); + Item(const Item &item); - /*! + /*! * Copies the contents of \a item into this Item. */ - Item &operator=(const Item &item); + Item &operator=(const Item &item); - /*! + /*! * Exchanges the content of the Item by the content of \a item. */ - void swap(Item &item); + void swap(Item &item); - ~Item(); + ~Item(); - Item(int value); - Item(unsigned char value); - Item(unsigned int value); - Item(long long value); - Item(bool value); - Item(int first, int second); - Item(const StringList &value); - Item(const ByteVectorList &value); - Item(const CoverArtList &value); + Item(int value); + Item(unsigned char value); + Item(unsigned int value); + Item(long long value); + Item(bool value); + Item(int first, int second); + Item(const StringList &value); + Item(const ByteVectorList &value); + Item(const CoverArtList &value); - void setAtomDataType(AtomDataType type); - AtomDataType atomDataType() const; + void setAtomDataType(AtomDataType type); + AtomDataType atomDataType() const; - int toInt() const; - unsigned char toByte() const; - unsigned int toUInt() const; - long long toLongLong() const; - bool toBool() const; - IntPair toIntPair() const; - StringList toStringList() const; - ByteVectorList toByteVectorList() const; - CoverArtList toCoverArtList() const; + int toInt() const; + unsigned char toByte() const; + unsigned int toUInt() const; + long long toLongLong() const; + bool toBool() const; + IntPair toIntPair() const; + StringList toStringList() const; + ByteVectorList toByteVectorList() const; + CoverArtList toCoverArtList() const; - bool isValid() const; + bool isValid() const; - private: - class ItemPrivate; - ItemPrivate *d; - }; + private: + class ItemPrivate; + ItemPrivate *d; +}; - } +} // namespace MP4 -} -} +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mp4/mp4properties.cpp b/3rdparty/taglib/mp4/mp4properties.cpp index ad1de269c..74ec6579d 100644 --- a/3rdparty/taglib/mp4/mp4properties.cpp +++ b/3rdparty/taglib/mp4/mp4properties.cpp @@ -31,17 +31,15 @@ using namespace Strawberry_TagLib::TagLib; -class MP4::Properties::PropertiesPrivate -{ -public: - PropertiesPrivate() : - length(0), - bitrate(0), - sampleRate(0), - channels(0), - bitsPerSample(0), - encrypted(false), - codec(MP4::Properties::Unknown) {} +class MP4::Properties::PropertiesPrivate { + public: + PropertiesPrivate() : length(0), + bitrate(0), + sampleRate(0), + channels(0), + bitsPerSample(0), + encrypted(false), + codec(MP4::Properties::Unknown) {} int length; int bitrate; @@ -56,69 +54,49 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -MP4::Properties::Properties(File *file, MP4::Atoms *atoms, ReadStyle style) : - AudioProperties(style), - d(new PropertiesPrivate()) -{ +MP4::Properties::Properties(File *file, MP4::Atoms *atoms, ReadStyle style) : AudioProperties(style), + d(new PropertiesPrivate()) { read(file, atoms); } -MP4::Properties::~Properties() -{ +MP4::Properties::~Properties() { delete d; } -int -MP4::Properties::channels() const -{ +int MP4::Properties::channels() const { return d->channels; } -int -MP4::Properties::sampleRate() const -{ +int MP4::Properties::sampleRate() const { return d->sampleRate; } -int -MP4::Properties::length() const -{ +int MP4::Properties::length() const { return lengthInSeconds(); } -int -MP4::Properties::lengthInSeconds() const -{ +int MP4::Properties::lengthInSeconds() const { return d->length / 1000; } -int -MP4::Properties::lengthInMilliseconds() const -{ +int MP4::Properties::lengthInMilliseconds() const { return d->length; } -int -MP4::Properties::bitrate() const -{ +int MP4::Properties::bitrate() const { return d->bitrate; } -int -MP4::Properties::bitsPerSample() const -{ +int MP4::Properties::bitsPerSample() const { return d->bitsPerSample; } -bool -MP4::Properties::isEncrypted() const -{ +bool MP4::Properties::isEncrypted() const { return d->encrypted; } MP4::Properties::Codec -MP4::Properties::codec() const -{ +MP4::Properties::codec() const { return d->codec; } @@ -126,11 +104,9 @@ MP4::Properties::codec() const // private members //////////////////////////////////////////////////////////////////////////////// -void -MP4::Properties::read(File *file, Atoms *atoms) -{ +void MP4::Properties::read(File *file, Atoms *atoms) { MP4::Atom *moov = atoms->find("moov"); - if(!moov) { + if (!moov) { debug("MP4: Atom 'moov' not found"); return; } @@ -139,27 +115,27 @@ MP4::Properties::read(File *file, Atoms *atoms) ByteVector data; const MP4::AtomList trakList = moov->findall("trak"); - for(MP4::AtomList::ConstIterator it = trakList.begin(); it != trakList.end(); ++it) { + for (MP4::AtomList::ConstIterator it = trakList.begin(); it != trakList.end(); ++it) { trak = *it; MP4::Atom *hdlr = trak->find("mdia", "hdlr"); - if(!hdlr) { + if (!hdlr) { debug("MP4: Atom 'trak.mdia.hdlr' not found"); return; } file->seek(hdlr->offset); data = file->readBlock(hdlr->length); - if(data.containsAt("soun", 16)) { + if (data.containsAt("soun", 16)) { break; } trak = 0; } - if(!trak) { + if (!trak) { debug("MP4: No audio tracks"); return; } MP4::Atom *mdhd = trak->find("mdia", "mdhd"); - if(!mdhd) { + if (!mdhd) { debug("MP4: Atom 'trak.mdia.mdhd' not found"); return; } @@ -170,46 +146,46 @@ MP4::Properties::read(File *file, Atoms *atoms) const unsigned int version = data[8]; long long unit; long long length; - if(version == 1) { - if(data.size() < 36 + 8) { + if (version == 1) { + if (data.size() < 36 + 8) { debug("MP4: Atom 'trak.mdia.mdhd' is smaller than expected"); return; } - unit = data.toUInt(28U); + unit = data.toUInt(28U); length = data.toLongLong(32U); } else { - if(data.size() < 24 + 8) { + if (data.size() < 24 + 8) { debug("MP4: Atom 'trak.mdia.mdhd' is smaller than expected"); return; } - unit = data.toUInt(20U); + unit = data.toUInt(20U); length = data.toUInt(24U); } - if(unit > 0 && length > 0) + if (unit > 0 && length > 0) d->length = static_cast(length * 1000.0 / unit + 0.5); MP4::Atom *atom = trak->find("mdia", "minf", "stbl", "stsd"); - if(!atom) { + if (!atom) { return; } file->seek(atom->offset); data = file->readBlock(atom->length); - if(data.containsAt("mp4a", 20)) { - d->codec = AAC; - d->channels = data.toShort(40U); + if (data.containsAt("mp4a", 20)) { + d->codec = AAC; + d->channels = data.toShort(40U); d->bitsPerSample = data.toShort(42U); - d->sampleRate = data.toUInt(46U); - if(data.containsAt("esds", 56) && data[64] == 0x03) { + d->sampleRate = data.toUInt(46U); + if (data.containsAt("esds", 56) && data[64] == 0x03) { unsigned int pos = 65; - if(data.containsAt("\x80\x80\x80", pos)) { + if (data.containsAt("\x80\x80\x80", pos)) { pos += 3; } pos += 4; - if(data[pos] == 0x04) { + if (data[pos] == 0x04) { pos += 1; - if(data.containsAt("\x80\x80\x80", pos)) { + if (data.containsAt("\x80\x80\x80", pos)) { pos += 3; } pos += 10; @@ -217,18 +193,18 @@ MP4::Properties::read(File *file, Atoms *atoms) } } } - else if(data.containsAt("alac", 20)) { - if(atom->length == 88 && data.containsAt("alac", 56)) { - d->codec = ALAC; + else if (data.containsAt("alac", 20)) { + if (atom->length == 88 && data.containsAt("alac", 56)) { + d->codec = ALAC; d->bitsPerSample = data.at(69); - d->channels = data.at(73); - d->bitrate = static_cast(data.toUInt(80U) / 1000.0 + 0.5); - d->sampleRate = data.toUInt(84U); + d->channels = data.at(73); + d->bitrate = static_cast(data.toUInt(80U) / 1000.0 + 0.5); + d->sampleRate = data.toUInt(84U); } } MP4::Atom *drms = atom->find("drms"); - if(drms) { + if (drms) { d->encrypted = true; } } diff --git a/3rdparty/taglib/mp4/mp4properties.h b/3rdparty/taglib/mp4/mp4properties.h index 61d666228..d5d743cf2 100644 --- a/3rdparty/taglib/mp4/mp4properties.h +++ b/3rdparty/taglib/mp4/mp4properties.h @@ -32,25 +32,24 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace MP4 { +namespace MP4 { - class Atoms; - class File; +class Atoms; +class File; - //! An implementation of MP4 audio properties - class TAGLIB_EXPORT Properties : public AudioProperties - { - public: - enum Codec { - Unknown = 0, - AAC, - ALAC - }; +//! An implementation of MP4 audio properties +class TAGLIB_EXPORT Properties : public AudioProperties { + public: + enum Codec { + Unknown = 0, + AAC, + ALAC + }; - Properties(File *file, Atoms *atoms, ReadStyle style = Average); - virtual ~Properties(); + Properties(File *file, Atoms *atoms, ReadStyle style = Average); + virtual ~Properties(); - /*! + /*! * Returns the length of the file in seconds. The length is rounded down to * the nearest whole second. * @@ -58,65 +57,65 @@ namespace TagLib { * * \deprecated */ - TAGLIB_DEPRECATED virtual int length() const; + TAGLIB_DEPRECATED virtual int length() const; - /*! + /*! * Returns the length of the file in seconds. The length is rounded down to * the nearest whole second. * * \see lengthInMilliseconds() */ - // BIC: make virtual - int lengthInSeconds() const; + // BIC: make virtual + int lengthInSeconds() const; - /*! + /*! * Returns the length of the file in milliseconds. * * \see lengthInSeconds() */ - // BIC: make virtual - int lengthInMilliseconds() const; + // BIC: make virtual + int lengthInMilliseconds() const; - /*! + /*! * Returns the average bit rate of the file in kb/s. */ - virtual int bitrate() const; + virtual int bitrate() const; - /*! + /*! * Returns the sample rate in Hz. */ - virtual int sampleRate() const; + virtual int sampleRate() const; - /*! + /*! * Returns the number of audio channels. */ - virtual int channels() const; + virtual int channels() const; - /*! + /*! * Returns the number of bits per audio sample. */ - virtual int bitsPerSample() const; + virtual int bitsPerSample() const; - /*! + /*! * Returns whether or not the file is encrypted. */ - bool isEncrypted() const; + bool isEncrypted() const; - /*! + /*! * Returns the codec used in the file. */ - Codec codec() const; + Codec codec() const; - private: - void read(File *file, Atoms *atoms); + private: + void read(File *file, Atoms *atoms); - class PropertiesPrivate; - PropertiesPrivate *d; - }; + class PropertiesPrivate; + PropertiesPrivate *d; +}; - } +} // namespace MP4 -} -} +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mp4/mp4tag.cpp b/3rdparty/taglib/mp4/mp4tag.cpp index ccb0dd4c0..4870485a3 100644 --- a/3rdparty/taglib/mp4/mp4tag.cpp +++ b/3rdparty/taglib/mp4/mp4tag.cpp @@ -32,80 +32,75 @@ using namespace Strawberry_TagLib::TagLib; -class MP4::Tag::TagPrivate -{ -public: - TagPrivate() : - file(0), - atoms(0) {} +class MP4::Tag::TagPrivate { + public: + TagPrivate() : file(0), + atoms(0) {} Strawberry_TagLib::TagLib::File *file; Atoms *atoms; ItemMap items; }; -MP4::Tag::Tag() : - d(new TagPrivate()) -{ +MP4::Tag::Tag() : d(new TagPrivate()) { } -MP4::Tag::Tag(Strawberry_TagLib::TagLib::File *file, MP4::Atoms *atoms) : - d(new TagPrivate()) -{ +MP4::Tag::Tag(Strawberry_TagLib::TagLib::File *file, MP4::Atoms *atoms) : d(new TagPrivate()) { d->file = file; d->atoms = atoms; MP4::Atom *ilst = atoms->find("moov", "udta", "meta", "ilst"); - if(!ilst) { + if (!ilst) { //debug("Atom moov.udta.meta.ilst not found."); return; } - for(AtomList::ConstIterator it = ilst->children.begin(); it != ilst->children.end(); ++it) { + for (AtomList::ConstIterator it = ilst->children.begin(); it != ilst->children.end(); ++it) { MP4::Atom *atom = *it; file->seek(atom->offset + 8); - if(atom->name == "----") { + if (atom->name == "----") { parseFreeForm(atom); } - else if(atom->name == "trkn" || atom->name == "disk") { + else if (atom->name == "trkn" || atom->name == "disk") { parseIntPair(atom); } - else if(atom->name == "cpil" || atom->name == "pgap" || atom->name == "pcst" || - atom->name == "hdvd" || atom->name == "shwm") { + else if (atom->name == "cpil" || atom->name == "pgap" || atom->name == "pcst" || + atom->name == "hdvd" || atom->name == "shwm") { parseBool(atom); } - else if(atom->name == "tmpo" || atom->name == "\251mvi" || atom->name == "\251mvc") { + else if (atom->name == "tmpo" || atom->name == "\251mvi" || atom->name == "\251mvc") { parseInt(atom); } - else if(atom->name == "rate") { + else if (atom->name == "rate") { AtomDataList data = parseData2(atom); - if(!data.isEmpty()) { + if (!data.isEmpty()) { AtomData val = data[0]; if (val.type == TypeUTF8) { addItem(atom->name, StringList(String(val.data, String::UTF8))); - } else { + } + else { addItem(atom->name, (int)(val.data.toShort())); } } } - else if(atom->name == "tvsn" || atom->name == "tves" || atom->name == "cnID" || - atom->name == "sfID" || atom->name == "atID" || atom->name == "geID" || - atom->name == "cmID") { + else if (atom->name == "tvsn" || atom->name == "tves" || atom->name == "cnID" || + atom->name == "sfID" || atom->name == "atID" || atom->name == "geID" || + atom->name == "cmID") { parseUInt(atom); } - else if(atom->name == "plID") { + else if (atom->name == "plID") { parseLongLong(atom); } - else if(atom->name == "stik" || atom->name == "rtng" || atom->name == "akID") { + else if (atom->name == "stik" || atom->name == "rtng" || atom->name == "akID") { parseByte(atom); } - else if(atom->name == "gnre") { + else if (atom->name == "gnre") { parseGnre(atom); } - else if(atom->name == "covr") { + else if (atom->name == "covr") { parseCovr(atom); } - else if(atom->name == "purl" || atom->name == "egid") { + else if (atom->name == "purl" || atom->name == "egid") { parseText(atom, -1); } else { @@ -114,44 +109,42 @@ MP4::Tag::Tag(Strawberry_TagLib::TagLib::File *file, MP4::Atoms *atoms) : } } -MP4::Tag::~Tag() -{ +MP4::Tag::~Tag() { delete d; } MP4::AtomDataList -MP4::Tag::parseData2(const MP4::Atom *atom, int expectedFlags, bool freeForm) -{ +MP4::Tag::parseData2(const MP4::Atom *atom, int expectedFlags, bool freeForm) { AtomDataList result; ByteVector data = d->file->readBlock(atom->length - 8); int i = 0; unsigned int pos = 0; - while(pos < data.size()) { + while (pos < data.size()) { const int length = static_cast(data.toUInt(pos)); - if(length < 12) { + if (length < 12) { debug("MP4: Too short atom"); return result; } const ByteVector name = data.mid(pos + 4, 4); const int flags = static_cast(data.toUInt(pos + 8)); - if(freeForm && i < 2) { - if(i == 0 && name != "mean") { + if (freeForm && i < 2) { + if (i == 0 && name != "mean") { debug("MP4: Unexpected atom \"" + name + "\", expecting \"mean\""); return result; } - else if(i == 1 && name != "name") { + else if (i == 1 && name != "name") { debug("MP4: Unexpected atom \"" + name + "\", expecting \"name\""); return result; } result.append(AtomData(AtomDataType(flags), data.mid(pos + 12, length - 12))); } else { - if(name != "data") { + if (name != "data") { debug("MP4: Unexpected atom \"" + name + "\", expecting \"data\""); return result; } - if(expectedFlags == -1 || flags == expectedFlags) { + if (expectedFlags == -1 || flags == expectedFlags) { result.append(AtomData(AtomDataType(flags), data.mid(pos + 16, length - 16))); } } @@ -162,103 +155,84 @@ MP4::Tag::parseData2(const MP4::Atom *atom, int expectedFlags, bool freeForm) } ByteVectorList -MP4::Tag::parseData(const MP4::Atom *atom, int expectedFlags, bool freeForm) -{ +MP4::Tag::parseData(const MP4::Atom *atom, int expectedFlags, bool freeForm) { AtomDataList data = parseData2(atom, expectedFlags, freeForm); ByteVectorList result; - for(AtomDataList::ConstIterator it = data.begin(); it != data.end(); ++it) { + for (AtomDataList::ConstIterator it = data.begin(); it != data.end(); ++it) { result.append(it->data); } return result; } -void -MP4::Tag::parseInt(const MP4::Atom *atom) -{ +void MP4::Tag::parseInt(const MP4::Atom *atom) { ByteVectorList data = parseData(atom); - if(!data.isEmpty()) { + if (!data.isEmpty()) { addItem(atom->name, (int)data[0].toShort()); } } -void -MP4::Tag::parseUInt(const MP4::Atom *atom) -{ +void MP4::Tag::parseUInt(const MP4::Atom *atom) { ByteVectorList data = parseData(atom); - if(!data.isEmpty()) { + if (!data.isEmpty()) { addItem(atom->name, data[0].toUInt()); } } -void -MP4::Tag::parseLongLong(const MP4::Atom *atom) -{ +void MP4::Tag::parseLongLong(const MP4::Atom *atom) { ByteVectorList data = parseData(atom); - if(!data.isEmpty()) { + if (!data.isEmpty()) { addItem(atom->name, data[0].toLongLong()); } } -void -MP4::Tag::parseByte(const MP4::Atom *atom) -{ +void MP4::Tag::parseByte(const MP4::Atom *atom) { ByteVectorList data = parseData(atom); - if(!data.isEmpty()) { + if (!data.isEmpty()) { addItem(atom->name, static_cast(data[0].at(0))); } } -void -MP4::Tag::parseGnre(const MP4::Atom *atom) -{ +void MP4::Tag::parseGnre(const MP4::Atom *atom) { ByteVectorList data = parseData(atom); - if(!data.isEmpty()) { + if (!data.isEmpty()) { int idx = (int)data[0].toShort(); - if(idx > 0) { + if (idx > 0) { addItem("\251gen", StringList(ID3v1::genre(idx - 1))); } } } -void -MP4::Tag::parseIntPair(const MP4::Atom *atom) -{ +void MP4::Tag::parseIntPair(const MP4::Atom *atom) { ByteVectorList data = parseData(atom); - if(!data.isEmpty()) { + if (!data.isEmpty()) { const int a = data[0].toShort(2U); const int b = data[0].toShort(4U); addItem(atom->name, MP4::Item(a, b)); } } -void -MP4::Tag::parseBool(const MP4::Atom *atom) -{ +void MP4::Tag::parseBool(const MP4::Atom *atom) { ByteVectorList data = parseData(atom); - if(!data.isEmpty()) { + if (!data.isEmpty()) { bool value = data[0].size() ? data[0][0] != '\0' : false; addItem(atom->name, value); } } -void -MP4::Tag::parseText(const MP4::Atom *atom, int expectedFlags) -{ +void MP4::Tag::parseText(const MP4::Atom *atom, int expectedFlags) { ByteVectorList data = parseData(atom, expectedFlags); - if(!data.isEmpty()) { + if (!data.isEmpty()) { StringList value; - for(ByteVectorList::ConstIterator it = data.begin(); it != data.end(); ++it) { + for (ByteVectorList::ConstIterator it = data.begin(); it != data.end(); ++it) { value.append(String(*it, String::UTF8)); } addItem(atom->name, value); } } -void -MP4::Tag::parseFreeForm(const MP4::Atom *atom) -{ +void MP4::Tag::parseFreeForm(const MP4::Atom *atom) { AtomDataList data = parseData2(atom, -1, true); - if(data.size() > 2) { + if (data.size() > 2) { AtomDataList::ConstIterator itBegin = data.begin(); String name = "----:"; @@ -266,17 +240,17 @@ MP4::Tag::parseFreeForm(const MP4::Atom *atom) name += ':'; name += String((itBegin++)->data, String::UTF8); // data[1].data - AtomDataType type = itBegin->type; // data[2].type + AtomDataType type = itBegin->type; // data[2].type - for(AtomDataList::ConstIterator it = itBegin; it != data.end(); ++it) { - if(it->type != type) { + for (AtomDataList::ConstIterator it = itBegin; it != data.end(); ++it) { + if (it->type != type) { debug("MP4: We currently don't support values with multiple types"); break; } } - if(type == TypeUTF8) { + if (type == TypeUTF8) { StringList value; - for(AtomDataList::ConstIterator it = itBegin; it != data.end(); ++it) { + for (AtomDataList::ConstIterator it = itBegin; it != data.end(); ++it) { value.append(String(it->data, String::UTF8)); } Item item(value); @@ -285,7 +259,7 @@ MP4::Tag::parseFreeForm(const MP4::Atom *atom) } else { ByteVectorList value; - for(AtomDataList::ConstIterator it = itBegin; it != data.end(); ++it) { + for (AtomDataList::ConstIterator it = itBegin; it != data.end(); ++it) { value.append(it->data); } Item item(value); @@ -295,153 +269,138 @@ MP4::Tag::parseFreeForm(const MP4::Atom *atom) } } -void -MP4::Tag::parseCovr(const MP4::Atom *atom) -{ +void MP4::Tag::parseCovr(const MP4::Atom *atom) { MP4::CoverArtList value; ByteVector data = d->file->readBlock(atom->length - 8); unsigned int pos = 0; - while(pos < data.size()) { + while (pos < data.size()) { const int length = static_cast(data.toUInt(pos)); - if(length < 12) { + if (length < 12) { debug("MP4: Too short atom"); - break;; + break; + ; } const ByteVector name = data.mid(pos + 4, 4); const int flags = static_cast(data.toUInt(pos + 8)); - if(name != "data") { + if (name != "data") { debug("MP4: Unexpected atom \"" + name + "\", expecting \"data\""); break; } - if(flags == TypeJPEG || flags == TypePNG || flags == TypeBMP || - flags == TypeGIF || flags == TypeImplicit) { + if (flags == TypeJPEG || flags == TypePNG || flags == TypeBMP || + flags == TypeGIF || flags == TypeImplicit) { value.append(MP4::CoverArt(MP4::CoverArt::Format(flags), - data.mid(pos + 16, length - 16))); + data.mid(pos + 16, length - 16))); } else { debug("MP4: Unknown covr format " + String::number(flags)); } pos += length; } - if(!value.isEmpty()) + if (!value.isEmpty()) addItem(atom->name, value); } ByteVector -MP4::Tag::padIlst(const ByteVector &data, int length) const -{ - if(length == -1) { +MP4::Tag::padIlst(const ByteVector &data, int length) const { + if (length == -1) { length = ((data.size() + 1023) & ~1023) - data.size(); } return renderAtom("free", ByteVector(length, '\1')); } ByteVector -MP4::Tag::renderAtom(const ByteVector &name, const ByteVector &data) const -{ +MP4::Tag::renderAtom(const ByteVector &name, const ByteVector &data) const { return ByteVector::fromUInt(data.size() + 8) + name + data; } ByteVector -MP4::Tag::renderData(const ByteVector &name, int flags, const ByteVectorList &data) const -{ +MP4::Tag::renderData(const ByteVector &name, int flags, const ByteVectorList &data) const { ByteVector result; - for(ByteVectorList::ConstIterator it = data.begin(); it != data.end(); ++it) { + for (ByteVectorList::ConstIterator it = data.begin(); it != data.end(); ++it) { result.append(renderAtom("data", ByteVector::fromUInt(flags) + ByteVector(4, '\0') + *it)); } return renderAtom(name, result); } ByteVector -MP4::Tag::renderBool(const ByteVector &name, const MP4::Item &item) const -{ +MP4::Tag::renderBool(const ByteVector &name, const MP4::Item &item) const { ByteVectorList data; data.append(ByteVector(1, item.toBool() ? '\1' : '\0')); return renderData(name, TypeInteger, data); } ByteVector -MP4::Tag::renderInt(const ByteVector &name, const MP4::Item &item) const -{ +MP4::Tag::renderInt(const ByteVector &name, const MP4::Item &item) const { ByteVectorList data; data.append(ByteVector::fromShort(item.toInt())); return renderData(name, TypeInteger, data); } ByteVector -MP4::Tag::renderUInt(const ByteVector &name, const MP4::Item &item) const -{ +MP4::Tag::renderUInt(const ByteVector &name, const MP4::Item &item) const { ByteVectorList data; data.append(ByteVector::fromUInt(item.toUInt())); return renderData(name, TypeInteger, data); } ByteVector -MP4::Tag::renderLongLong(const ByteVector &name, const MP4::Item &item) const -{ +MP4::Tag::renderLongLong(const ByteVector &name, const MP4::Item &item) const { ByteVectorList data; data.append(ByteVector::fromLongLong(item.toLongLong())); return renderData(name, TypeInteger, data); } ByteVector -MP4::Tag::renderByte(const ByteVector &name, const MP4::Item &item) const -{ +MP4::Tag::renderByte(const ByteVector &name, const MP4::Item &item) const { ByteVectorList data; data.append(ByteVector(1, item.toByte())); return renderData(name, TypeInteger, data); } ByteVector -MP4::Tag::renderIntPair(const ByteVector &name, const MP4::Item &item) const -{ +MP4::Tag::renderIntPair(const ByteVector &name, const MP4::Item &item) const { ByteVectorList data; data.append(ByteVector(2, '\0') + - ByteVector::fromShort(item.toIntPair().first) + - ByteVector::fromShort(item.toIntPair().second) + - ByteVector(2, '\0')); + ByteVector::fromShort(item.toIntPair().first) + + ByteVector::fromShort(item.toIntPair().second) + + ByteVector(2, '\0')); return renderData(name, TypeImplicit, data); } ByteVector -MP4::Tag::renderIntPairNoTrailing(const ByteVector &name, const MP4::Item &item) const -{ +MP4::Tag::renderIntPairNoTrailing(const ByteVector &name, const MP4::Item &item) const { ByteVectorList data; data.append(ByteVector(2, '\0') + - ByteVector::fromShort(item.toIntPair().first) + - ByteVector::fromShort(item.toIntPair().second)); + ByteVector::fromShort(item.toIntPair().first) + + ByteVector::fromShort(item.toIntPair().second)); return renderData(name, TypeImplicit, data); } ByteVector -MP4::Tag::renderText(const ByteVector &name, const MP4::Item &item, int flags) const -{ +MP4::Tag::renderText(const ByteVector &name, const MP4::Item &item, int flags) const { ByteVectorList data; StringList value = item.toStringList(); - for(StringList::ConstIterator it = value.begin(); it != value.end(); ++it) { + for (StringList::ConstIterator it = value.begin(); it != value.end(); ++it) { data.append(it->data(String::UTF8)); } return renderData(name, flags, data); } ByteVector -MP4::Tag::renderCovr(const ByteVector &name, const MP4::Item &item) const -{ +MP4::Tag::renderCovr(const ByteVector &name, const MP4::Item &item) const { ByteVector data; MP4::CoverArtList value = item.toCoverArtList(); - for(MP4::CoverArtList::ConstIterator it = value.begin(); it != value.end(); ++it) { - data.append(renderAtom("data", ByteVector::fromUInt(it->format()) + - ByteVector(4, '\0') + it->data())); + for (MP4::CoverArtList::ConstIterator it = value.begin(); it != value.end(); ++it) { + data.append(renderAtom("data", ByteVector::fromUInt(it->format()) + ByteVector(4, '\0') + it->data())); } return renderAtom(name, data); } ByteVector -MP4::Tag::renderFreeForm(const String &name, const MP4::Item &item) const -{ +MP4::Tag::renderFreeForm(const String &name, const MP4::Item &item) const { StringList header = StringList::split(name, ":"); - if(header.size() != 3) { + if (header.size() != 3) { debug("MP4: Invalid free-form item name \"" + name + "\""); return ByteVector(); } @@ -449,53 +408,51 @@ MP4::Tag::renderFreeForm(const String &name, const MP4::Item &item) const data.append(renderAtom("mean", ByteVector::fromUInt(0) + header[1].data(String::UTF8))); data.append(renderAtom("name", ByteVector::fromUInt(0) + header[2].data(String::UTF8))); AtomDataType type = item.atomDataType(); - if(type == TypeUndefined) { - if(!item.toStringList().isEmpty()) { + if (type == TypeUndefined) { + if (!item.toStringList().isEmpty()) { type = TypeUTF8; } else { type = TypeImplicit; } } - if(type == TypeUTF8) { + if (type == TypeUTF8) { StringList value = item.toStringList(); - for(StringList::ConstIterator it = value.begin(); it != value.end(); ++it) { + for (StringList::ConstIterator it = value.begin(); it != value.end(); ++it) { data.append(renderAtom("data", ByteVector::fromUInt(type) + ByteVector(4, '\0') + it->data(String::UTF8))); } } else { ByteVectorList value = item.toByteVectorList(); - for(ByteVectorList::ConstIterator it = value.begin(); it != value.end(); ++it) { + for (ByteVectorList::ConstIterator it = value.begin(); it != value.end(); ++it) { data.append(renderAtom("data", ByteVector::fromUInt(type) + ByteVector(4, '\0') + *it)); } } return renderAtom("----", data); } -bool -MP4::Tag::save() -{ +bool MP4::Tag::save() { ByteVector data; - for(MP4::ItemMap::ConstIterator it = d->items.begin(); it != d->items.end(); ++it) { + for (MP4::ItemMap::ConstIterator it = d->items.begin(); it != d->items.end(); ++it) { const String name = it->first; - if(name.startsWith("----")) { + if (name.startsWith("----")) { data.append(renderFreeForm(name, it->second)); } - else if(name == "trkn") { + else if (name == "trkn") { data.append(renderIntPair(name.data(String::Latin1), it->second)); } - else if(name == "disk") { + else if (name == "disk") { data.append(renderIntPairNoTrailing(name.data(String::Latin1), it->second)); } - else if(name == "cpil" || name == "pgap" || name == "pcst" || name == "hdvd" || - name == "shwm") { + else if (name == "cpil" || name == "pgap" || name == "pcst" || name == "hdvd" || + name == "shwm") { data.append(renderBool(name.data(String::Latin1), it->second)); } - else if(name == "tmpo" || name == "\251mvi" || name == "\251mvc") { + else if (name == "tmpo" || name == "\251mvi" || name == "\251mvc") { data.append(renderInt(name.data(String::Latin1), it->second)); } else if (name == "rate") { - const MP4::Item& item = it->second; + const MP4::Item &item = it->second; StringList value = item.toStringList(); if (value.isEmpty()) { data.append(renderInt(name.data(String::Latin1), item)); @@ -504,24 +461,24 @@ MP4::Tag::save() data.append(renderText(name.data(String::Latin1), item)); } } - else if(name == "tvsn" || name == "tves" || name == "cnID" || - name == "sfID" || name == "atID" || name == "geID" || - name == "cmID") { + else if (name == "tvsn" || name == "tves" || name == "cnID" || + name == "sfID" || name == "atID" || name == "geID" || + name == "cmID") { data.append(renderUInt(name.data(String::Latin1), it->second)); } - else if(name == "plID") { + else if (name == "plID") { data.append(renderLongLong(name.data(String::Latin1), it->second)); } - else if(name == "stik" || name == "rtng" || name == "akID") { + else if (name == "stik" || name == "rtng" || name == "akID") { data.append(renderByte(name.data(String::Latin1), it->second)); } - else if(name == "covr") { + else if (name == "covr") { data.append(renderCovr(name.data(String::Latin1), it->second)); } - else if(name == "purl" || name == "egid") { + else if (name == "purl" || name == "egid") { data.append(renderText(name.data(String::Latin1), it->second, TypeImplicit)); } - else if(name.size() == 4){ + else if (name.size() == 4) { data.append(renderText(name.data(String::Latin1), it->second)); } else { @@ -531,7 +488,7 @@ MP4::Tag::save() data = renderAtom("ilst", data); AtomList path = d->atoms->path("moov", "udta", "meta", "ilst"); - if(path.size() == 4) { + if (path.size() == 4) { saveExisting(data, path); } else { @@ -541,21 +498,19 @@ MP4::Tag::save() return true; } -void -MP4::Tag::updateParents(const AtomList &path, long delta, int ignore) -{ - if(static_cast(path.size()) <= ignore) +void MP4::Tag::updateParents(const AtomList &path, long delta, int ignore) { + if (static_cast(path.size()) <= ignore) return; AtomList::ConstIterator itEnd = path.end(); std::advance(itEnd, 0 - ignore); - for(AtomList::ConstIterator it = path.begin(); it != itEnd; ++it) { + for (AtomList::ConstIterator it = path.begin(); it != itEnd; ++it) { d->file->seek((*it)->offset); long size = d->file->readBlock(4).toUInt(); // 64-bit if (size == 1) { - d->file->seek(4, File::Current); // Skip name + d->file->seek(4, File::Current); // Skip name long long longSize = d->file->readBlock(8).toLongLong(); // Seek the offset of the 64-bit size d->file->seek((*it)->offset + 8); @@ -569,15 +524,13 @@ MP4::Tag::updateParents(const AtomList &path, long delta, int ignore) } } -void -MP4::Tag::updateOffsets(long delta, long offset) -{ +void MP4::Tag::updateOffsets(long delta, long offset) { MP4::Atom *moov = d->atoms->find("moov"); - if(moov) { + if (moov) { MP4::AtomList stco = moov->findall("stco", true); - for(MP4::AtomList::ConstIterator it = stco.begin(); it != stco.end(); ++it) { + for (MP4::AtomList::ConstIterator it = stco.begin(); it != stco.end(); ++it) { MP4::Atom *atom = *it; - if(atom->offset > offset) { + if (atom->offset > offset) { atom->offset += delta; } d->file->seek(atom->offset + 12); @@ -585,9 +538,9 @@ MP4::Tag::updateOffsets(long delta, long offset) unsigned int count = data.toUInt(); d->file->seek(atom->offset + 16); unsigned int pos = 4; - while(count--) { + while (count--) { long o = static_cast(data.toUInt(pos)); - if(o > offset) { + if (o > offset) { o += delta; } d->file->writeBlock(ByteVector::fromUInt(o)); @@ -596,9 +549,9 @@ MP4::Tag::updateOffsets(long delta, long offset) } MP4::AtomList co64 = moov->findall("co64", true); - for(MP4::AtomList::ConstIterator it = co64.begin(); it != co64.end(); ++it) { + for (MP4::AtomList::ConstIterator it = co64.begin(); it != co64.end(); ++it) { MP4::Atom *atom = *it; - if(atom->offset > offset) { + if (atom->offset > offset) { atom->offset += delta; } d->file->seek(atom->offset + 12); @@ -606,9 +559,9 @@ MP4::Tag::updateOffsets(long delta, long offset) unsigned int count = data.toUInt(); d->file->seek(atom->offset + 16); unsigned int pos = 4; - while(count--) { + while (count--) { long long o = data.toLongLong(pos); - if(o > offset) { + if (o > offset) { o += delta; } d->file->writeBlock(ByteVector::fromLongLong(o)); @@ -618,19 +571,19 @@ MP4::Tag::updateOffsets(long delta, long offset) } MP4::Atom *moof = d->atoms->find("moof"); - if(moof) { + if (moof) { MP4::AtomList tfhd = moof->findall("tfhd", true); - for(MP4::AtomList::ConstIterator it = tfhd.begin(); it != tfhd.end(); ++it) { + for (MP4::AtomList::ConstIterator it = tfhd.begin(); it != tfhd.end(); ++it) { MP4::Atom *atom = *it; - if(atom->offset > offset) { + if (atom->offset > offset) { atom->offset += delta; } d->file->seek(atom->offset + 9); ByteVector data = d->file->readBlock(atom->length - 9); const unsigned int flags = data.toUInt(0, 3, true); - if(flags & 1) { + if (flags & 1) { long long o = data.toLongLong(7U); - if(o > offset) { + if (o > offset) { o += delta; } d->file->seek(atom->offset + 16); @@ -640,16 +593,11 @@ MP4::Tag::updateOffsets(long delta, long offset) } } -void -MP4::Tag::saveNew(ByteVector data) -{ - data = renderAtom("meta", ByteVector(4, '\0') + - renderAtom("hdlr", ByteVector(8, '\0') + ByteVector("mdirappl") + - ByteVector(9, '\0')) + - data + padIlst(data)); +void MP4::Tag::saveNew(ByteVector data) { + data = renderAtom("meta", ByteVector(4, '\0') + renderAtom("hdlr", ByteVector(8, '\0') + ByteVector("mdirappl") + ByteVector(9, '\0')) + data + padIlst(data)); AtomList path = d->atoms->path("moov", "udta"); - if(path.size() != 2) { + if (path.size() != 2) { path = d->atoms->path("moov"); data = renderAtom("udta", data); } @@ -666,9 +614,7 @@ MP4::Tag::saveNew(ByteVector data) path.back()->children.prepend(new Atom(d->file)); } -void -MP4::Tag::saveExisting(ByteVector data, const AtomList &path) -{ +void MP4::Tag::saveExisting(ByteVector data, const AtomList &path) { AtomList::ConstIterator it = path.end(); MP4::Atom *ilst = *(--it); @@ -679,11 +625,11 @@ MP4::Tag::saveExisting(ByteVector data, const AtomList &path) AtomList::ConstIterator index = meta->children.find(ilst); // check if there is an atom before 'ilst', and possibly use it as padding - if(index != meta->children.begin()) { + if (index != meta->children.begin()) { AtomList::ConstIterator prevIndex = index; prevIndex--; MP4::Atom *prev = *prevIndex; - if(prev->name == "free") { + if (prev->name == "free") { offset = prev->offset; length += prev->length; } @@ -691,120 +637,101 @@ MP4::Tag::saveExisting(ByteVector data, const AtomList &path) // check if there is an atom after 'ilst', and possibly use it as padding AtomList::ConstIterator nextIndex = index; nextIndex++; - if(nextIndex != meta->children.end()) { + if (nextIndex != meta->children.end()) { MP4::Atom *next = *nextIndex; - if(next->name == "free") { + if (next->name == "free") { length += next->length; } } long delta = data.size() - length; - if(delta > 0 || (delta < 0 && delta > -8)) { + if (delta > 0 || (delta < 0 && delta > -8)) { data.append(padIlst(data)); delta = data.size() - length; } - else if(delta < 0) { + else if (delta < 0) { data.append(padIlst(data, -delta - 8)); delta = 0; } d->file->insert(data, offset, length); - if(delta) { + if (delta) { updateParents(path, delta, 1); updateOffsets(delta, offset); } } String -MP4::Tag::title() const -{ - if(d->items.contains("\251nam")) +MP4::Tag::title() const { + if (d->items.contains("\251nam")) return d->items["\251nam"].toStringList().toString(", "); return String(); } String -MP4::Tag::artist() const -{ - if(d->items.contains("\251ART")) +MP4::Tag::artist() const { + if (d->items.contains("\251ART")) return d->items["\251ART"].toStringList().toString(", "); return String(); } String -MP4::Tag::album() const -{ - if(d->items.contains("\251alb")) +MP4::Tag::album() const { + if (d->items.contains("\251alb")) return d->items["\251alb"].toStringList().toString(", "); return String(); } String -MP4::Tag::comment() const -{ - if(d->items.contains("\251cmt")) +MP4::Tag::comment() const { + if (d->items.contains("\251cmt")) return d->items["\251cmt"].toStringList().toString(", "); return String(); } String -MP4::Tag::genre() const -{ - if(d->items.contains("\251gen")) +MP4::Tag::genre() const { + if (d->items.contains("\251gen")) return d->items["\251gen"].toStringList().toString(", "); return String(); } unsigned int -MP4::Tag::year() const -{ - if(d->items.contains("\251day")) +MP4::Tag::year() const { + if (d->items.contains("\251day")) return d->items["\251day"].toStringList().toString().toInt(); return 0; } unsigned int -MP4::Tag::track() const -{ - if(d->items.contains("trkn")) +MP4::Tag::track() const { + if (d->items.contains("trkn")) return d->items["trkn"].toIntPair().first; return 0; } -void -MP4::Tag::setTitle(const String &value) -{ +void MP4::Tag::setTitle(const String &value) { d->items["\251nam"] = StringList(value); } -void -MP4::Tag::setArtist(const String &value) -{ +void MP4::Tag::setArtist(const String &value) { d->items["\251ART"] = StringList(value); } -void -MP4::Tag::setAlbum(const String &value) -{ +void MP4::Tag::setAlbum(const String &value) { d->items["\251alb"] = StringList(value); } -void -MP4::Tag::setComment(const String &value) -{ +void MP4::Tag::setComment(const String &value) { d->items["\251cmt"] = StringList(value); } -void -MP4::Tag::setGenre(const String &value) -{ +void MP4::Tag::setGenre(const String &value) { d->items["\251gen"] = StringList(value); } -void -MP4::Tag::setYear(unsigned int value) -{ +void MP4::Tag::setYear(unsigned int value) { if (value == 0) { d->items.erase("\251day"); } @@ -813,9 +740,7 @@ MP4::Tag::setYear(unsigned int value) } } -void -MP4::Tag::setTrack(unsigned int value) -{ +void MP4::Tag::setTrack(unsigned int value) { if (value == 0) { d->items.erase("trkn"); } @@ -824,128 +749,118 @@ MP4::Tag::setTrack(unsigned int value) } } -bool MP4::Tag::isEmpty() const -{ +bool MP4::Tag::isEmpty() const { return d->items.isEmpty(); } -MP4::ItemMap &MP4::Tag::itemListMap() -{ +MP4::ItemMap &MP4::Tag::itemListMap() { return d->items; } -const MP4::ItemMap &MP4::Tag::itemMap() const -{ +const MP4::ItemMap &MP4::Tag::itemMap() const { return d->items; } -MP4::Item MP4::Tag::item(const String &key) const -{ +MP4::Item MP4::Tag::item(const String &key) const { return d->items[key]; } -void MP4::Tag::setItem(const String &key, const Item &value) -{ +void MP4::Tag::setItem(const String &key, const Item &value) { d->items[key] = value; } -void MP4::Tag::removeItem(const String &key) -{ +void MP4::Tag::removeItem(const String &key) { d->items.erase(key); } -bool MP4::Tag::contains(const String &key) const -{ +bool MP4::Tag::contains(const String &key) const { return d->items.contains(key); } -namespace -{ - const char *keyTranslation[][2] = { - { "\251nam", "TITLE" }, - { "\251ART", "ARTIST" }, - { "\251alb", "ALBUM" }, - { "\251cmt", "COMMENT" }, - { "\251gen", "GENRE" }, - { "\251day", "DATE" }, - { "\251wrt", "COMPOSER" }, - { "\251grp", "GROUPING" }, - { "aART", "ALBUMARTIST" }, - { "trkn", "TRACKNUMBER" }, - { "disk", "DISCNUMBER" }, - { "cpil", "COMPILATION" }, - { "tmpo", "BPM" }, - { "cprt", "COPYRIGHT" }, - { "\251lyr", "LYRICS" }, - { "\251too", "ENCODEDBY" }, - { "soal", "ALBUMSORT" }, - { "soaa", "ALBUMARTISTSORT" }, - { "soar", "ARTISTSORT" }, - { "sonm", "TITLESORT" }, - { "soco", "COMPOSERSORT" }, - { "sosn", "SHOWSORT" }, - { "shwm", "SHOWWORKMOVEMENT" }, - { "\251wrk", "WORK" }, - { "\251mvn", "MOVEMENTNAME" }, - { "\251mvi", "MOVEMENTNUMBER" }, - { "\251mvc", "MOVEMENTCOUNT" }, - { "----:com.apple.iTunes:MusicBrainz Track Id", "MUSICBRAINZ_TRACKID" }, - { "----:com.apple.iTunes:MusicBrainz Artist Id", "MUSICBRAINZ_ARTISTID" }, - { "----:com.apple.iTunes:MusicBrainz Album Id", "MUSICBRAINZ_ALBUMID" }, - { "----:com.apple.iTunes:MusicBrainz Album Artist Id", "MUSICBRAINZ_ALBUMARTISTID" }, - { "----:com.apple.iTunes:MusicBrainz Release Group Id", "MUSICBRAINZ_RELEASEGROUPID" }, - { "----:com.apple.iTunes:MusicBrainz Work Id", "MUSICBRAINZ_WORKID" }, - { "----:com.apple.iTunes:ASIN", "ASIN" }, - { "----:com.apple.iTunes:LABEL", "LABEL" }, - { "----:com.apple.iTunes:LYRICIST", "LYRICIST" }, - { "----:com.apple.iTunes:CONDUCTOR", "CONDUCTOR" }, - { "----:com.apple.iTunes:REMIXER", "REMIXER" }, - { "----:com.apple.iTunes:ENGINEER", "ENGINEER" }, - { "----:com.apple.iTunes:PRODUCER", "PRODUCER" }, - { "----:com.apple.iTunes:DJMIXER", "DJMIXER" }, - { "----:com.apple.iTunes:MIXER", "MIXER" }, - { "----:com.apple.iTunes:SUBTITLE", "SUBTITLE" }, - { "----:com.apple.iTunes:DISCSUBTITLE", "DISCSUBTITLE" }, - { "----:com.apple.iTunes:MOOD", "MOOD" }, - { "----:com.apple.iTunes:ISRC", "ISRC" }, - { "----:com.apple.iTunes:CATALOGNUMBER", "CATALOGNUMBER" }, - { "----:com.apple.iTunes:BARCODE", "BARCODE" }, - { "----:com.apple.iTunes:SCRIPT", "SCRIPT" }, - { "----:com.apple.iTunes:LANGUAGE", "LANGUAGE" }, - { "----:com.apple.iTunes:LICENSE", "LICENSE" }, - { "----:com.apple.iTunes:MEDIA", "MEDIA" }, - }; - const size_t keyTranslationSize = sizeof(keyTranslation) / sizeof(keyTranslation[0]); +namespace { +const char *keyTranslation[][2] = { + { "\251nam", "TITLE" }, + { "\251ART", "ARTIST" }, + { "\251alb", "ALBUM" }, + { "\251cmt", "COMMENT" }, + { "\251gen", "GENRE" }, + { "\251day", "DATE" }, + { "\251wrt", "COMPOSER" }, + { "\251grp", "GROUPING" }, + { "aART", "ALBUMARTIST" }, + { "trkn", "TRACKNUMBER" }, + { "disk", "DISCNUMBER" }, + { "cpil", "COMPILATION" }, + { "tmpo", "BPM" }, + { "cprt", "COPYRIGHT" }, + { "\251lyr", "LYRICS" }, + { "\251too", "ENCODEDBY" }, + { "soal", "ALBUMSORT" }, + { "soaa", "ALBUMARTISTSORT" }, + { "soar", "ARTISTSORT" }, + { "sonm", "TITLESORT" }, + { "soco", "COMPOSERSORT" }, + { "sosn", "SHOWSORT" }, + { "shwm", "SHOWWORKMOVEMENT" }, + { "\251wrk", "WORK" }, + { "\251mvn", "MOVEMENTNAME" }, + { "\251mvi", "MOVEMENTNUMBER" }, + { "\251mvc", "MOVEMENTCOUNT" }, + { "----:com.apple.iTunes:MusicBrainz Track Id", "MUSICBRAINZ_TRACKID" }, + { "----:com.apple.iTunes:MusicBrainz Artist Id", "MUSICBRAINZ_ARTISTID" }, + { "----:com.apple.iTunes:MusicBrainz Album Id", "MUSICBRAINZ_ALBUMID" }, + { "----:com.apple.iTunes:MusicBrainz Album Artist Id", "MUSICBRAINZ_ALBUMARTISTID" }, + { "----:com.apple.iTunes:MusicBrainz Release Group Id", "MUSICBRAINZ_RELEASEGROUPID" }, + { "----:com.apple.iTunes:MusicBrainz Work Id", "MUSICBRAINZ_WORKID" }, + { "----:com.apple.iTunes:ASIN", "ASIN" }, + { "----:com.apple.iTunes:LABEL", "LABEL" }, + { "----:com.apple.iTunes:LYRICIST", "LYRICIST" }, + { "----:com.apple.iTunes:CONDUCTOR", "CONDUCTOR" }, + { "----:com.apple.iTunes:REMIXER", "REMIXER" }, + { "----:com.apple.iTunes:ENGINEER", "ENGINEER" }, + { "----:com.apple.iTunes:PRODUCER", "PRODUCER" }, + { "----:com.apple.iTunes:DJMIXER", "DJMIXER" }, + { "----:com.apple.iTunes:MIXER", "MIXER" }, + { "----:com.apple.iTunes:SUBTITLE", "SUBTITLE" }, + { "----:com.apple.iTunes:DISCSUBTITLE", "DISCSUBTITLE" }, + { "----:com.apple.iTunes:MOOD", "MOOD" }, + { "----:com.apple.iTunes:ISRC", "ISRC" }, + { "----:com.apple.iTunes:CATALOGNUMBER", "CATALOGNUMBER" }, + { "----:com.apple.iTunes:BARCODE", "BARCODE" }, + { "----:com.apple.iTunes:SCRIPT", "SCRIPT" }, + { "----:com.apple.iTunes:LANGUAGE", "LANGUAGE" }, + { "----:com.apple.iTunes:LICENSE", "LICENSE" }, + { "----:com.apple.iTunes:MEDIA", "MEDIA" }, +}; +const size_t keyTranslationSize = sizeof(keyTranslation) / sizeof(keyTranslation[0]); - String translateKey(const String &key) - { - for(size_t i = 0; i < keyTranslationSize; ++i) { - if(key == keyTranslation[i][0]) - return keyTranslation[i][1]; - } - - return String(); +String translateKey(const String &key) { + for (size_t i = 0; i < keyTranslationSize; ++i) { + if (key == keyTranslation[i][0]) + return keyTranslation[i][1]; } -} -PropertyMap MP4::Tag::properties() const -{ + return String(); +} +} // namespace + +PropertyMap MP4::Tag::properties() const { PropertyMap props; - for(MP4::ItemMap::ConstIterator it = d->items.begin(); it != d->items.end(); ++it) { + for (MP4::ItemMap::ConstIterator it = d->items.begin(); it != d->items.end(); ++it) { const String key = translateKey(it->first); - if(!key.isEmpty()) { - if(key == "TRACKNUMBER" || key == "DISCNUMBER") { + if (!key.isEmpty()) { + if (key == "TRACKNUMBER" || key == "DISCNUMBER") { MP4::Item::IntPair ip = it->second.toIntPair(); String value = String::number(ip.first); - if(ip.second) { + if (ip.second) { value += "/" + String::number(ip.second); } props[key] = value; } - else if(key == "BPM" || key == "MOVEMENTNUMBER" || key == "MOVEMENTCOUNT") { + else if (key == "BPM" || key == "MOVEMENTNUMBER" || key == "MOVEMENTCOUNT") { props[key] = String::number(it->second.toInt()); } - else if(key == "COMPILATION" || key == "SHOWWORKMOVEMENT") { + else if (key == "COMPILATION" || key == "SHOWWORKMOVEMENT") { props[key] = String::number(it->second.toBool()); } else { @@ -959,49 +874,47 @@ PropertyMap MP4::Tag::properties() const return props; } -void MP4::Tag::removeUnsupportedProperties(const StringList &props) -{ - for(StringList::ConstIterator it = props.begin(); it != props.end(); ++it) +void MP4::Tag::removeUnsupportedProperties(const StringList &props) { + for (StringList::ConstIterator it = props.begin(); it != props.end(); ++it) d->items.erase(*it); } -PropertyMap MP4::Tag::setProperties(const PropertyMap &props) -{ +PropertyMap MP4::Tag::setProperties(const PropertyMap &props) { static Map reverseKeyMap; - if(reverseKeyMap.isEmpty()) { + if (reverseKeyMap.isEmpty()) { int numKeys = sizeof(keyTranslation) / sizeof(keyTranslation[0]); - for(int i = 0; i < numKeys; i++) { + for (int i = 0; i < numKeys; i++) { reverseKeyMap[keyTranslation[i][1]] = keyTranslation[i][0]; } } PropertyMap origProps = properties(); - for(PropertyMap::ConstIterator it = origProps.begin(); it != origProps.end(); ++it) { - if(!props.contains(it->first) || props[it->first].isEmpty()) { + for (PropertyMap::ConstIterator it = origProps.begin(); it != origProps.end(); ++it) { + if (!props.contains(it->first) || props[it->first].isEmpty()) { d->items.erase(reverseKeyMap[it->first]); } } PropertyMap ignoredProps; - for(PropertyMap::ConstIterator it = props.begin(); it != props.end(); ++it) { - if(reverseKeyMap.contains(it->first)) { + for (PropertyMap::ConstIterator it = props.begin(); it != props.end(); ++it) { + if (reverseKeyMap.contains(it->first)) { String name = reverseKeyMap[it->first]; - if((it->first == "TRACKNUMBER" || it->first == "DISCNUMBER") && !it->second.isEmpty()) { + if ((it->first == "TRACKNUMBER" || it->first == "DISCNUMBER") && !it->second.isEmpty()) { StringList parts = StringList::split(it->second.front(), "/"); - if(!parts.isEmpty()) { + if (!parts.isEmpty()) { int first = parts[0].toInt(); int second = 0; - if(parts.size() > 1) { + if (parts.size() > 1) { second = parts[1].toInt(); } d->items[name] = MP4::Item(first, second); } } - else if((it->first == "BPM" || it->first == "MOVEMENTNUMBER" || it->first == "MOVEMENTCOUNT") && !it->second.isEmpty()) { + else if ((it->first == "BPM" || it->first == "MOVEMENTNUMBER" || it->first == "MOVEMENTCOUNT") && !it->second.isEmpty()) { int value = it->second.front().toInt(); d->items[name] = MP4::Item(value); } - else if((it->first == "COMPILATION" || it->first == "SHOWWORKMOVEMENT") && !it->second.isEmpty()) { + else if ((it->first == "COMPILATION" || it->first == "SHOWWORKMOVEMENT") && !it->second.isEmpty()) { bool value = (it->second.front().toInt() != 0); d->items[name] = MP4::Item(value); } @@ -1017,9 +930,8 @@ PropertyMap MP4::Tag::setProperties(const PropertyMap &props) return ignoredProps; } -void MP4::Tag::addItem(const String &name, const Item &value) -{ - if(!d->items.contains(name)) { +void MP4::Tag::addItem(const String &name, const Item &value) { + if (!d->items.contains(name)) { d->items.insert(name, value); } else { diff --git a/3rdparty/taglib/mp4/mp4tag.h b/3rdparty/taglib/mp4/mp4tag.h index d139f39b2..421831a9d 100644 --- a/3rdparty/taglib/mp4/mp4tag.h +++ b/3rdparty/taglib/mp4/mp4tag.h @@ -38,122 +38,121 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace MP4 { +namespace MP4 { - /*! +/*! * \deprecated */ - TAGLIB_DEPRECATED typedef Strawberry_TagLib::TagLib::Map ItemListMap; - typedef Strawberry_TagLib::TagLib::Map ItemMap; +TAGLIB_DEPRECATED typedef Strawberry_TagLib::TagLib::Map ItemListMap; +typedef Strawberry_TagLib::TagLib::Map ItemMap; - class TAGLIB_EXPORT Tag: public Strawberry_TagLib::TagLib::Tag - { - public: - Tag(); - Tag(Strawberry_TagLib::TagLib::File *file, Atoms *atoms); - virtual ~Tag(); - bool save(); +class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag { + public: + Tag(); + Tag(Strawberry_TagLib::TagLib::File *file, Atoms *atoms); + virtual ~Tag(); + bool save(); - virtual String title() const; - virtual String artist() const; - virtual String album() const; - virtual String comment() const; - virtual String genre() const; - virtual unsigned int year() const; - virtual unsigned int track() const; + virtual String title() const; + virtual String artist() const; + virtual String album() const; + virtual String comment() const; + virtual String genre() const; + virtual unsigned int year() const; + virtual unsigned int track() const; - virtual void setTitle(const String &value); - virtual void setArtist(const String &value); - virtual void setAlbum(const String &value); - virtual void setComment(const String &value); - virtual void setGenre(const String &value); - virtual void setYear(unsigned int value); - virtual void setTrack(unsigned int value); + virtual void setTitle(const String &value); + virtual void setArtist(const String &value); + virtual void setAlbum(const String &value); + virtual void setComment(const String &value); + virtual void setGenre(const String &value); + virtual void setYear(unsigned int value); + virtual void setTrack(unsigned int value); - virtual bool isEmpty() const; + virtual bool isEmpty() const; - /*! + /*! * \deprecated Use the item() and setItem() API instead */ - TAGLIB_DEPRECATED ItemMap &itemListMap(); + TAGLIB_DEPRECATED ItemMap &itemListMap(); - /*! + /*! * Returns a string-keyed map of the MP4::Items for this tag. */ - const ItemMap &itemMap() const; + const ItemMap &itemMap() const; - /*! + /*! * \return The item, if any, corresponding to \a key. */ - Item item(const String &key) const; + Item item(const String &key) const; - /*! + /*! * Sets the value of \a key to \a value, overwriting any previous value. */ - void setItem(const String &key, const Item &value); + void setItem(const String &key, const Item &value); - /*! + /*! * Removes the entry with \a key from the tag, or does nothing if it does * not exist. */ - void removeItem(const String &key); + void removeItem(const String &key); - /*! + /*! * \return True if the tag contains an entry for \a key. */ - bool contains(const String &key) const; + bool contains(const String &key) const; - PropertyMap properties() const; - void removeUnsupportedProperties(const StringList& properties); - PropertyMap setProperties(const PropertyMap &properties); + PropertyMap properties() const; + void removeUnsupportedProperties(const StringList &properties); + PropertyMap setProperties(const PropertyMap &properties); - private: - AtomDataList parseData2(const Atom *atom, int expectedFlags = -1, - bool freeForm = false); - ByteVectorList parseData(const Atom *atom, int expectedFlags = -1, - bool freeForm = false); - void parseText(const Atom *atom, int expectedFlags = 1); - void parseFreeForm(const Atom *atom); - void parseInt(const Atom *atom); - void parseByte(const Atom *atom); - void parseUInt(const Atom *atom); - void parseLongLong(const Atom *atom); - void parseGnre(const Atom *atom); - void parseIntPair(const Atom *atom); - void parseBool(const Atom *atom); - void parseCovr(const Atom *atom); + private: + AtomDataList parseData2(const Atom *atom, int expectedFlags = -1, + bool freeForm = false); + ByteVectorList parseData(const Atom *atom, int expectedFlags = -1, + bool freeForm = false); + void parseText(const Atom *atom, int expectedFlags = 1); + void parseFreeForm(const Atom *atom); + void parseInt(const Atom *atom); + void parseByte(const Atom *atom); + void parseUInt(const Atom *atom); + void parseLongLong(const Atom *atom); + void parseGnre(const Atom *atom); + void parseIntPair(const Atom *atom); + void parseBool(const Atom *atom); + void parseCovr(const Atom *atom); - ByteVector padIlst(const ByteVector &data, int length = -1) const; - ByteVector renderAtom(const ByteVector &name, const ByteVector &data) const; - ByteVector renderData(const ByteVector &name, int flags, - const ByteVectorList &data) const; - ByteVector renderText(const ByteVector &name, const Item &item, - int flags = TypeUTF8) const; - ByteVector renderFreeForm(const String &name, const Item &item) const; - ByteVector renderBool(const ByteVector &name, const Item &item) const; - ByteVector renderInt(const ByteVector &name, const Item &item) const; - ByteVector renderByte(const ByteVector &name, const Item &item) const; - ByteVector renderUInt(const ByteVector &name, const Item &item) const; - ByteVector renderLongLong(const ByteVector &name, const Item &item) const; - ByteVector renderIntPair(const ByteVector &name, const Item &item) const; - ByteVector renderIntPairNoTrailing(const ByteVector &name, const Item &item) const; - ByteVector renderCovr(const ByteVector &name, const Item &item) const; + ByteVector padIlst(const ByteVector &data, int length = -1) const; + ByteVector renderAtom(const ByteVector &name, const ByteVector &data) const; + ByteVector renderData(const ByteVector &name, int flags, + const ByteVectorList &data) const; + ByteVector renderText(const ByteVector &name, const Item &item, + int flags = TypeUTF8) const; + ByteVector renderFreeForm(const String &name, const Item &item) const; + ByteVector renderBool(const ByteVector &name, const Item &item) const; + ByteVector renderInt(const ByteVector &name, const Item &item) const; + ByteVector renderByte(const ByteVector &name, const Item &item) const; + ByteVector renderUInt(const ByteVector &name, const Item &item) const; + ByteVector renderLongLong(const ByteVector &name, const Item &item) const; + ByteVector renderIntPair(const ByteVector &name, const Item &item) const; + ByteVector renderIntPairNoTrailing(const ByteVector &name, const Item &item) const; + ByteVector renderCovr(const ByteVector &name, const Item &item) const; - void updateParents(const AtomList &path, long delta, int ignore = 0); - void updateOffsets(long delta, long offset); + void updateParents(const AtomList &path, long delta, int ignore = 0); + void updateOffsets(long delta, long offset); - void saveNew(ByteVector data); - void saveExisting(ByteVector data, const AtomList &path); + void saveNew(ByteVector data); + void saveExisting(ByteVector data, const AtomList &path); - void addItem(const String &name, const Item &value); + void addItem(const String &name, const Item &value); - class TagPrivate; - TagPrivate *d; - }; + class TagPrivate; + TagPrivate *d; +}; - } +} // namespace MP4 -} -} +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpc/mpcfile.cpp b/3rdparty/taglib/mpc/mpcfile.cpp index fa82427e6..b76845381 100644 --- a/3rdparty/taglib/mpc/mpcfile.cpp +++ b/3rdparty/taglib/mpc/mpcfile.cpp @@ -38,25 +38,22 @@ using namespace Strawberry_TagLib::TagLib; -namespace -{ - enum { MPCAPEIndex = 0, MPCID3v1Index = 1 }; +namespace { +enum { MPCAPEIndex = 0, + MPCID3v1Index = 1 }; } -class MPC::File::FilePrivate -{ -public: - FilePrivate() : - APELocation(-1), - APESize(0), - ID3v1Location(-1), - ID3v2Header(0), - ID3v2Location(-1), - ID3v2Size(0), - properties(0) {} +class MPC::File::FilePrivate { + public: + FilePrivate() : APELocation(-1), + APESize(0), + ID3v1Location(-1), + ID3v2Header(0), + ID3v2Location(-1), + ID3v2Size(0), + properties(0) {} - ~FilePrivate() - { + ~FilePrivate() { delete ID3v2Header; delete properties; } @@ -79,8 +76,7 @@ public: // static members //////////////////////////////////////////////////////////////////////////////// -bool MPC::File::isSupported(IOStream *stream) -{ +bool MPC::File::isSupported(IOStream *stream) { // A newer MPC file has to start with "MPCK" or "MP+", but older files don't // have keys to do a quick check. @@ -92,71 +88,60 @@ bool MPC::File::isSupported(IOStream *stream) // public members //////////////////////////////////////////////////////////////////////////////// -MPC::File::File(FileName file, bool readProperties, Properties::ReadStyle) : - Strawberry_TagLib::TagLib::File(file), - d(new FilePrivate()) -{ - if(isOpen()) +MPC::File::File(FileName file, bool readProperties, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(file), + d(new FilePrivate()) { + if (isOpen()) read(readProperties); } -MPC::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) : - Strawberry_TagLib::TagLib::File(stream), - d(new FilePrivate()) -{ - if(isOpen()) +MPC::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(stream), + d(new FilePrivate()) { + if (isOpen()) read(readProperties); } -MPC::File::~File() -{ +MPC::File::~File() { delete d; } -Strawberry_TagLib::TagLib::Tag *MPC::File::tag() const -{ +Strawberry_TagLib::TagLib::Tag *MPC::File::tag() const { return &d->tag; } -PropertyMap MPC::File::properties() const -{ +PropertyMap MPC::File::properties() const { return d->tag.properties(); } -void MPC::File::removeUnsupportedProperties(const StringList &properties) -{ +void MPC::File::removeUnsupportedProperties(const StringList &properties) { d->tag.removeUnsupportedProperties(properties); } -PropertyMap MPC::File::setProperties(const PropertyMap &properties) -{ - if(ID3v1Tag()) +PropertyMap MPC::File::setProperties(const PropertyMap &properties) { + if (ID3v1Tag()) ID3v1Tag()->setProperties(properties); return APETag(true)->setProperties(properties); } -MPC::Properties *MPC::File::audioProperties() const -{ +MPC::Properties *MPC::File::audioProperties() const { return d->properties; } -bool MPC::File::save() -{ - if(readOnly()) { +bool MPC::File::save() { + if (readOnly()) { debug("MPC::File::save() -- File is read only."); return false; } // Possibly strip ID3v2 tag - if(!d->ID3v2Header && d->ID3v2Location >= 0) { + if (!d->ID3v2Header && d->ID3v2Location >= 0) { removeBlock(d->ID3v2Location, d->ID3v2Size); - if(d->APELocation >= 0) + if (d->APELocation >= 0) d->APELocation -= d->ID3v2Size; - if(d->ID3v1Location >= 0) + if (d->ID3v1Location >= 0) d->ID3v1Location -= d->ID3v2Size; d->ID3v2Location = -1; @@ -165,11 +150,11 @@ bool MPC::File::save() // Update ID3v1 tag - if(ID3v1Tag() && !ID3v1Tag()->isEmpty()) { + if (ID3v1Tag() && !ID3v1Tag()->isEmpty()) { // ID3v1 tag is not empty. Update the old one or create a new one. - if(d->ID3v1Location >= 0) { + if (d->ID3v1Location >= 0) { seek(d->ID3v1Location); } else { @@ -183,7 +168,7 @@ bool MPC::File::save() // ID3v1 tag is empty. Remove the old one. - if(d->ID3v1Location >= 0) { + if (d->ID3v1Location >= 0) { truncate(d->ID3v1Location); d->ID3v1Location = -1; } @@ -191,12 +176,12 @@ bool MPC::File::save() // Update APE tag - if(APETag() && !APETag()->isEmpty()) { + if (APETag() && !APETag()->isEmpty()) { // APE tag is not empty. Update the old one or create a new one. - if(d->APELocation < 0) { - if(d->ID3v1Location >= 0) + if (d->APELocation < 0) { + if (d->ID3v1Location >= 0) d->APELocation = d->ID3v1Location; else d->APELocation = length(); @@ -205,7 +190,7 @@ bool MPC::File::save() const ByteVector data = APETag()->render(); insert(data, d->APELocation, d->APESize); - if(d->ID3v1Location >= 0) + if (d->ID3v1Location >= 0) d->ID3v1Location += (static_cast(data.size()) - d->APESize); d->APESize = data.size(); @@ -214,10 +199,10 @@ bool MPC::File::save() // APE tag is empty. Remove the old one. - if(d->APELocation >= 0) { + if (d->APELocation >= 0) { removeBlock(d->APELocation, d->APESize); - if(d->ID3v1Location >= 0) + if (d->ID3v1Location >= 0) d->ID3v1Location -= d->APESize; d->APELocation = -1; @@ -228,45 +213,39 @@ bool MPC::File::save() return true; } -ID3v1::Tag *MPC::File::ID3v1Tag(bool create) -{ +ID3v1::Tag *MPC::File::ID3v1Tag(bool create) { return d->tag.access(MPCID3v1Index, create); } -APE::Tag *MPC::File::APETag(bool create) -{ +APE::Tag *MPC::File::APETag(bool create) { return d->tag.access(MPCAPEIndex, create); } -void MPC::File::strip(int tags) -{ - if(tags & ID3v1) +void MPC::File::strip(int tags) { + if (tags & ID3v1) d->tag.set(MPCID3v1Index, 0); - if(tags & APE) + if (tags & APE) d->tag.set(MPCAPEIndex, 0); - if(!ID3v1Tag()) + if (!ID3v1Tag()) APETag(true); - if(tags & ID3v2) { + if (tags & ID3v2) { delete d->ID3v2Header; d->ID3v2Header = 0; } } -void MPC::File::remove(int tags) -{ +void MPC::File::remove(int tags) { strip(tags); } -bool MPC::File::hasID3v1Tag() const -{ +bool MPC::File::hasID3v1Tag() const { return (d->ID3v1Location >= 0); } -bool MPC::File::hasAPETag() const -{ +bool MPC::File::hasAPETag() const { return (d->APELocation >= 0); } @@ -274,13 +253,12 @@ bool MPC::File::hasAPETag() const // private members //////////////////////////////////////////////////////////////////////////////// -void MPC::File::read(bool readProperties) -{ +void MPC::File::read(bool readProperties) { // Look for an ID3v2 tag d->ID3v2Location = Utils::findID3v2(this); - if(d->ID3v2Location >= 0) { + if (d->ID3v2Location >= 0) { seek(d->ID3v2Location); d->ID3v2Header = new ID3v2::Header(readBlock(ID3v2::Header::size())); d->ID3v2Size = d->ID3v2Header->completeTagSize(); @@ -290,36 +268,36 @@ void MPC::File::read(bool readProperties) d->ID3v1Location = Utils::findID3v1(this); - if(d->ID3v1Location >= 0) + if (d->ID3v1Location >= 0) d->tag.set(MPCID3v1Index, new ID3v1::Tag(this, d->ID3v1Location)); // Look for an APE tag d->APELocation = Utils::findAPE(this, d->ID3v1Location); - if(d->APELocation >= 0) { + if (d->APELocation >= 0) { d->tag.set(MPCAPEIndex, new APE::Tag(this, d->APELocation)); d->APESize = APETag()->footer()->completeTagSize(); d->APELocation = d->APELocation + APE::Footer::size() - d->APESize; } - if(d->ID3v1Location < 0) + if (d->ID3v1Location < 0) APETag(true); // Look for MPC metadata - if(readProperties) { + if (readProperties) { long streamLength; - if(d->APELocation >= 0) + if (d->APELocation >= 0) streamLength = d->APELocation; - else if(d->ID3v1Location >= 0) + else if (d->ID3v1Location >= 0) streamLength = d->ID3v1Location; else streamLength = length(); - if(d->ID3v2Location >= 0) { + if (d->ID3v2Location >= 0) { seek(d->ID3v2Location + d->ID3v2Size); streamLength -= (d->ID3v2Location + d->ID3v2Size); } diff --git a/3rdparty/taglib/mpc/mpcfile.h b/3rdparty/taglib/mpc/mpcfile.h index 0ad3fe152..7931a7066 100644 --- a/3rdparty/taglib/mpc/mpcfile.h +++ b/3rdparty/taglib/mpc/mpcfile.h @@ -37,14 +37,18 @@ namespace Strawberry_TagLib { namespace TagLib { - class Tag; +class Tag; - namespace ID3v1 { class Tag; } - namespace APE { class Tag; } +namespace ID3v1 { +class Tag; +} +namespace APE { +class Tag; +} - //! An implementation of MPC metadata +//! An implementation of MPC metadata - /*! +/*! * This is implementation of MPC metadata. * * This supports ID3v1 and APE (v1 and v2) style comments as well as reading stream @@ -52,11 +56,11 @@ namespace TagLib { * and ignored. */ - namespace MPC { +namespace MPC { - //! An implementation of TagLib::File with MPC specific methods +//! An implementation of TagLib::File with MPC specific methods - /*! +/*! * This implements and provides an interface for MPC files to the * TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing * the abstract TagLib::File API as well as providing some additional @@ -64,36 +68,35 @@ namespace TagLib { * The only invalid tag combination supported is an ID3v1 tag after an APE tag. */ - class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File - { - public: - /*! +class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File { + public: + /*! * This set of flags is used for various operations and is suitable for * being OR-ed together. */ - enum TagTypes { - //! Empty set. Matches no tag types. - NoTags = 0x0000, - //! Matches ID3v1 tags. - ID3v1 = 0x0001, - //! Matches ID3v2 tags. - ID3v2 = 0x0002, - //! Matches APE tags. - APE = 0x0004, - //! Matches all tag types. - AllTags = 0xffff - }; + enum TagTypes { + //! Empty set. Matches no tag types. + NoTags = 0x0000, + //! Matches ID3v1 tags. + ID3v1 = 0x0001, + //! Matches ID3v2 tags. + ID3v2 = 0x0002, + //! Matches APE tags. + APE = 0x0004, + //! Matches all tag types. + AllTags = 0xffff + }; - /*! + /*! * Constructs an MPC file from \a file. If \a readProperties is true the * file's audio properties will also be read. * * \note In the current implementation, \a propertiesStyle is ignored. */ - File(FileName file, bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(FileName file, bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Constructs an MPC file from \a stream. If \a readProperties is true the * file's audio properties will also be read. * @@ -102,50 +105,50 @@ namespace TagLib { * * \note In the current implementation, \a propertiesStyle is ignored. */ - File(IOStream *stream, bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(IOStream *stream, bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Destroys this instance of the File. */ - virtual ~File(); + virtual ~File(); - /*! + /*! * Returns the Tag for this file. This will be an APE tag, an ID3v1 tag * or a combination of the two. */ - virtual Strawberry_TagLib::TagLib::Tag *tag() const; + virtual Strawberry_TagLib::TagLib::Tag *tag() const; - /*! + /*! * Implements the unified property interface -- export function. * If the file contains both an APE and an ID3v1 tag, only the APE * tag will be converted to the PropertyMap. */ - PropertyMap properties() const; + PropertyMap properties() const; - void removeUnsupportedProperties(const StringList &properties); + void removeUnsupportedProperties(const StringList &properties); - /*! + /*! * Implements the unified property interface -- import function. * Affects only the APEv2 tag which will be created if necessary. * If an ID3v1 tag exists, it will be updated as well. */ - PropertyMap setProperties(const PropertyMap &); + PropertyMap setProperties(const PropertyMap &); - /*! + /*! * Returns the MPC::Properties for this file. If no audio properties * were read then this will return a null pointer. */ - virtual Properties *audioProperties() const; + virtual Properties *audioProperties() const; - /*! + /*! * Saves the file. * * This returns true if the save was successful. */ - virtual bool save(); + virtual bool save(); - /*! + /*! * Returns a pointer to the ID3v1 tag of the file. * * If \a create is false (the default) this returns a null pointer @@ -162,9 +165,9 @@ namespace TagLib { * * \see hasID3v1Tag() */ - ID3v1::Tag *ID3v1Tag(bool create = false); + ID3v1::Tag *ID3v1Tag(bool create = false); - /*! + /*! * Returns a pointer to the APE tag of the file. * * If \a create is false (the default) this may return a null pointer @@ -182,9 +185,9 @@ namespace TagLib { * * \see hasAPETag() */ - APE::Tag *APETag(bool create = false); + APE::Tag *APETag(bool create = false); - /*! + /*! * This will remove the tags that match the OR-ed together TagTypes from the * file. By default it removes all tags. * @@ -193,48 +196,48 @@ namespace TagLib { * * \note In order to make the removal permanent save() still needs to be called. */ - void strip(int tags = AllTags); + void strip(int tags = AllTags); - /*! + /*! * \deprecated * \see strip */ - TAGLIB_DEPRECATED void remove(int tags = AllTags); + TAGLIB_DEPRECATED void remove(int tags = AllTags); - /*! + /*! * Returns whether or not the file on disk actually has an ID3v1 tag. * * \see ID3v1Tag() */ - bool hasID3v1Tag() const; + bool hasID3v1Tag() const; - /*! + /*! * Returns whether or not the file on disk actually has an APE tag. * * \see APETag() */ - bool hasAPETag() const; + bool hasAPETag() const; - /*! + /*! * Returns whether or not the given \a stream can be opened as an MPC * file. * * \note This method is designed to do a quick check. The result may * not necessarily be correct. */ - static bool isSupported(IOStream *stream); + static bool isSupported(IOStream *stream); - private: - File(const File &); - File &operator=(const File &); + private: + File(const File &); + File &operator=(const File &); - void read(bool readProperties); + void read(bool readProperties); - class FilePrivate; - FilePrivate *d; - }; - } -} -} + class FilePrivate; + FilePrivate *d; +}; +} // namespace MPC +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpc/mpcproperties.cpp b/3rdparty/taglib/mpc/mpcproperties.cpp index 627b9e3f5..cd551dc88 100644 --- a/3rdparty/taglib/mpc/mpcproperties.cpp +++ b/3rdparty/taglib/mpc/mpcproperties.cpp @@ -33,21 +33,19 @@ using namespace Strawberry_TagLib::TagLib; -class MPC::Properties::PropertiesPrivate -{ -public: - PropertiesPrivate() : - version(0), - length(0), - bitrate(0), - sampleRate(0), - channels(0), - totalFrames(0), - sampleFrames(0), - trackGain(0), - trackPeak(0), - albumGain(0), - albumPeak(0) {} +class MPC::Properties::PropertiesPrivate { + public: + PropertiesPrivate() : version(0), + length(0), + bitrate(0), + sampleRate(0), + channels(0), + totalFrames(0), + sampleFrames(0), + trackGain(0), + trackPeak(0), + albumGain(0), + albumPeak(0) {} int version; int length; @@ -66,19 +64,15 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -MPC::Properties::Properties(const ByteVector &data, long streamLength, ReadStyle style) : - AudioProperties(style), - d(new PropertiesPrivate()) -{ +MPC::Properties::Properties(const ByteVector &data, long streamLength, ReadStyle style) : AudioProperties(style), + d(new PropertiesPrivate()) { readSV7(data, streamLength); } -MPC::Properties::Properties(File *file, long streamLength, ReadStyle style) : - AudioProperties(style), - d(new PropertiesPrivate()) -{ +MPC::Properties::Properties(File *file, long streamLength, ReadStyle style) : AudioProperties(style), + d(new PropertiesPrivate()) { ByteVector magic = file->readBlock(4); - if(magic == "MPCK") { + if (magic == "MPCK") { // Musepack version 8 readSV8(file, streamLength); } @@ -88,73 +82,59 @@ MPC::Properties::Properties(File *file, long streamLength, ReadStyle style) : } } -MPC::Properties::~Properties() -{ +MPC::Properties::~Properties() { delete d; } -int MPC::Properties::length() const -{ +int MPC::Properties::length() const { return lengthInSeconds(); } -int MPC::Properties::lengthInSeconds() const -{ +int MPC::Properties::lengthInSeconds() const { return d->length / 1000; } -int MPC::Properties::lengthInMilliseconds() const -{ +int MPC::Properties::lengthInMilliseconds() const { return d->length; } -int MPC::Properties::bitrate() const -{ +int MPC::Properties::bitrate() const { return d->bitrate; } -int MPC::Properties::sampleRate() const -{ +int MPC::Properties::sampleRate() const { return d->sampleRate; } -int MPC::Properties::channels() const -{ +int MPC::Properties::channels() const { return d->channels; } -int MPC::Properties::mpcVersion() const -{ +int MPC::Properties::mpcVersion() const { return d->version; } -unsigned int MPC::Properties::totalFrames() const -{ +unsigned int MPC::Properties::totalFrames() const { return d->totalFrames; } -unsigned int MPC::Properties::sampleFrames() const -{ +unsigned int MPC::Properties::sampleFrames() const { return d->sampleFrames; } -int MPC::Properties::trackGain() const -{ +int MPC::Properties::trackGain() const { return d->trackGain; } -int MPC::Properties::trackPeak() const -{ +int MPC::Properties::trackPeak() const { return d->trackPeak; } -int MPC::Properties::albumGain() const -{ +int MPC::Properties::albumGain() const { return d->albumGain; } -int MPC::Properties::albumPeak() const -{ +int MPC::Properties::albumPeak() const { return d->albumPeak; } @@ -162,58 +142,54 @@ int MPC::Properties::albumPeak() const // private members //////////////////////////////////////////////////////////////////////////////// -namespace -{ - unsigned long readSize(File *file, unsigned int &sizeLength, bool &eof) - { - sizeLength = 0; - eof = false; +namespace { +unsigned long readSize(File *file, unsigned int &sizeLength, bool &eof) { + sizeLength = 0; + eof = false; - unsigned char tmp; - unsigned long size = 0; + unsigned char tmp; + unsigned long size = 0; - do { - const ByteVector b = file->readBlock(1); - if(b.isEmpty()) { - eof = true; - break; - } + do { + const ByteVector b = file->readBlock(1); + if (b.isEmpty()) { + eof = true; + break; + } - tmp = b[0]; - size = (size << 7) | (tmp & 0x7F); - sizeLength++; - } while((tmp & 0x80)); - return size; - } - - unsigned long readSize(const ByteVector &data, unsigned int &pos) - { - unsigned char tmp; - unsigned long size = 0; - - do { - tmp = data[pos++]; - size = (size << 7) | (tmp & 0x7F); - } while((tmp & 0x80) && (pos < data.size())); - return size; - } - - // This array looks weird, but the same as original MusePack code found at: - // https://www.musepack.net/index.php?pg=src - const unsigned short sftable [8] = { 44100, 48000, 37800, 32000, 0, 0, 0, 0 }; + tmp = b[0]; + size = (size << 7) | (tmp & 0x7F); + sizeLength++; + } while ((tmp & 0x80)); + return size; } -void MPC::Properties::readSV8(File *file, long streamLength) -{ +unsigned long readSize(const ByteVector &data, unsigned int &pos) { + unsigned char tmp; + unsigned long size = 0; + + do { + tmp = data[pos++]; + size = (size << 7) | (tmp & 0x7F); + } while ((tmp & 0x80) && (pos < data.size())); + return size; +} + +// This array looks weird, but the same as original MusePack code found at: +// https://www.musepack.net/index.php?pg=src +const unsigned short sftable[8] = { 44100, 48000, 37800, 32000, 0, 0, 0, 0 }; +} // namespace + +void MPC::Properties::readSV8(File *file, long streamLength) { bool readSH = false, readRG = false; - while(!readSH && !readRG) { + while (!readSH && !readRG) { const ByteVector packetType = file->readBlock(2); unsigned int packetSizeLength; bool eof; const unsigned long packetSize = readSize(file, packetSizeLength, eof); - if(eof) { + if (eof) { debug("MPC::Properties::readSV8() - Reached to EOF."); break; } @@ -221,16 +197,16 @@ void MPC::Properties::readSV8(File *file, long streamLength) const unsigned long dataSize = packetSize - 2 - packetSizeLength; const ByteVector data = file->readBlock(dataSize); - if(data.size() != dataSize) { + if (data.size() != dataSize) { debug("MPC::Properties::readSV8() - dataSize doesn't match the actual data size."); break; } - if(packetType == "SH") { + if (packetType == "SH") { // Stream Header // http://trac.musepack.net/wiki/SV8Specification#StreamHeaderPacket - if(dataSize <= 5) { + if (dataSize <= 5) { debug("MPC::Properties::readSV8() - \"SH\" packet is too short to parse."); break; } @@ -241,13 +217,13 @@ void MPC::Properties::readSV8(File *file, long streamLength) d->version = data[pos]; pos += 1; d->sampleFrames = readSize(data, pos); - if(pos > dataSize - 3) { + if (pos > dataSize - 3) { debug("MPC::Properties::readSV8() - \"SH\" packet is corrupt."); break; } const unsigned long begSilence = readSize(data, pos); - if(pos > dataSize - 2) { + if (pos > dataSize - 2) { debug("MPC::Properties::readSV8() - \"SH\" packet is corrupt."); break; } @@ -256,12 +232,12 @@ void MPC::Properties::readSV8(File *file, long streamLength) pos += 2; d->sampleRate = sftable[(flags >> 13) & 0x07]; - d->channels = ((flags >> 4) & 0x0F) + 1; + d->channels = ((flags >> 4) & 0x0F) + 1; const unsigned int frameCount = d->sampleFrames - begSilence; - if(frameCount > 0 && d->sampleRate > 0) { + if (frameCount > 0 && d->sampleRate > 0) { const double length = frameCount * 1000.0 / d->sampleRate; - d->length = static_cast(length + 0.5); + d->length = static_cast(length + 0.5); d->bitrate = static_cast(streamLength * 8.0 / length + 0.5); } } @@ -269,7 +245,7 @@ void MPC::Properties::readSV8(File *file, long streamLength) // Replay Gain // http://trac.musepack.net/wiki/SV8Specification#ReplaygainPacket - if(dataSize <= 9) { + if (dataSize <= 9) { debug("MPC::Properties::readSV8() - \"RG\" packet is too short to parse."); break; } @@ -277,7 +253,7 @@ void MPC::Properties::readSV8(File *file, long streamLength) readRG = true; const int replayGainVersion = data[0]; - if(replayGainVersion == 1) { + if (replayGainVersion == 1) { d->trackGain = data.toShort(1, true); d->trackPeak = data.toShort(3, true); d->albumGain = data.toShort(5, true); @@ -285,7 +261,7 @@ void MPC::Properties::readSV8(File *file, long streamLength) } } - else if(packetType == "SE") { + else if (packetType == "SE") { break; } @@ -295,18 +271,17 @@ void MPC::Properties::readSV8(File *file, long streamLength) } } -void MPC::Properties::readSV7(const ByteVector &data, long streamLength) -{ - if(data.startsWith("MP+")) { +void MPC::Properties::readSV7(const ByteVector &data, long streamLength) { + if (data.startsWith("MP+")) { d->version = data[3] & 15; - if(d->version < 7) + if (d->version < 7) return; d->totalFrames = data.toUInt(4, false); const unsigned int flags = data.toUInt(8, false); d->sampleRate = sftable[(flags >> 16) & 0x03]; - d->channels = 2; + d->channels = 2; const unsigned int gapless = data.toUInt(5, false); @@ -316,15 +291,15 @@ void MPC::Properties::readSV7(const ByteVector &data, long streamLength) d->albumPeak = data.toUShort(16, false); // convert gain info - if(d->trackGain != 0) { + if (d->trackGain != 0) { int tmp = (int)((64.82 - (short)d->trackGain / 100.) * 256. + .5); - if(tmp >= (1 << 16) || tmp < 0) tmp = 0; + if (tmp >= (1 << 16) || tmp < 0) tmp = 0; d->trackGain = tmp; } - if(d->albumGain != 0) { + if (d->albumGain != 0) { int tmp = (int)((64.82 - d->albumGain / 100.) * 256. + .5); - if(tmp >= (1 << 16) || tmp < 0) tmp = 0; + if (tmp >= (1 << 16) || tmp < 0) tmp = 0; d->albumGain = tmp; } @@ -335,7 +310,7 @@ void MPC::Properties::readSV7(const ByteVector &data, long streamLength) d->albumPeak = (int)(log10((double)d->albumPeak) * 20 * 256 + .5); bool trueGapless = (gapless >> 31) & 0x0001; - if(trueGapless) { + if (trueGapless) { unsigned int lastFrameSamples = (gapless >> 20) & 0x07FF; d->sampleFrames = d->totalFrames * 1152 - lastFrameSamples; } @@ -345,12 +320,12 @@ void MPC::Properties::readSV7(const ByteVector &data, long streamLength) else { const unsigned int headerData = data.toUInt(0, false); - d->bitrate = (headerData >> 23) & 0x01ff; - d->version = (headerData >> 11) & 0x03ff; + d->bitrate = (headerData >> 23) & 0x01ff; + d->version = (headerData >> 11) & 0x03ff; d->sampleRate = 44100; - d->channels = 2; + d->channels = 2; - if(d->version >= 5) + if (d->version >= 5) d->totalFrames = data.toUInt(4, false); else d->totalFrames = data.toUShort(6, false); @@ -358,11 +333,11 @@ void MPC::Properties::readSV7(const ByteVector &data, long streamLength) d->sampleFrames = d->totalFrames * 1152 - 576; } - if(d->sampleFrames > 0 && d->sampleRate > 0) { + if (d->sampleFrames > 0 && d->sampleRate > 0) { const double length = d->sampleFrames * 1000.0 / d->sampleRate; d->length = static_cast(length + 0.5); - if(d->bitrate == 0) + if (d->bitrate == 0) d->bitrate = static_cast(streamLength * 8.0 / length + 0.5); } } diff --git a/3rdparty/taglib/mpc/mpcproperties.h b/3rdparty/taglib/mpc/mpcproperties.h index 121ca29b7..857351a69 100644 --- a/3rdparty/taglib/mpc/mpcproperties.h +++ b/3rdparty/taglib/mpc/mpcproperties.h @@ -32,42 +32,41 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace MPC { +namespace MPC { - class File; +class File; - static const unsigned int HeaderSize = 8 * 7; +static const unsigned int HeaderSize = 8 * 7; - //! An implementation of audio property reading for MPC +//! An implementation of audio property reading for MPC - /*! +/*! * This reads the data from an MPC stream found in the AudioProperties * API. */ - class TAGLIB_EXPORT Properties : public AudioProperties - { - public: - /*! +class TAGLIB_EXPORT Properties : public AudioProperties { + public: + /*! * Create an instance of MPC::Properties with the data read from the * ByteVector \a data. * * This constructor is deprecated. It only works for MPC version up to 7. */ - Properties(const ByteVector &data, long streamLength, ReadStyle style = Average); + Properties(const ByteVector &data, long streamLength, ReadStyle style = Average); - /*! + /*! * Create an instance of MPC::Properties with the data read directly * from a MPC::File. */ - Properties(File *file, long streamLength, ReadStyle style = Average); + Properties(File *file, long streamLength, ReadStyle style = Average); - /*! + /*! * Destroys this MPC::Properties instance. */ - virtual ~Properties(); + virtual ~Properties(); - /*! + /*! * Returns the length of the file in seconds. The length is rounded down to * the nearest whole second. * @@ -75,86 +74,86 @@ namespace TagLib { * * \deprecated */ - TAGLIB_DEPRECATED virtual int length() const; + TAGLIB_DEPRECATED virtual int length() const; - /*! + /*! * Returns the length of the file in seconds. The length is rounded down to * the nearest whole second. * * \see lengthInMilliseconds() */ - // BIC: make virtual - int lengthInSeconds() const; + // BIC: make virtual + int lengthInSeconds() const; - /*! + /*! * Returns the length of the file in milliseconds. * * \see lengthInSeconds() */ - // BIC: make virtual - int lengthInMilliseconds() const; + // BIC: make virtual + int lengthInMilliseconds() const; - /*! + /*! * Returns the average bit rate of the file in kb/s. */ - virtual int bitrate() const; + virtual int bitrate() const; - /*! + /*! * Returns the sample rate in Hz. */ - virtual int sampleRate() const; + virtual int sampleRate() const; - /*! + /*! * Returns the number of audio channels. */ - virtual int channels() const; + virtual int channels() const; - /*! + /*! * Returns the version of the bitstream (SV4-SV8) */ - int mpcVersion() const; + int mpcVersion() const; - unsigned int totalFrames() const; - unsigned int sampleFrames() const; + unsigned int totalFrames() const; + unsigned int sampleFrames() const; - /*! + /*! * Returns the track gain as an integer value, * to convert to dB: trackGain in dB = 64.82 - (trackGain / 256) */ - int trackGain() const; + int trackGain() const; - /*! + /*! * Returns the track peak as an integer value, * to convert to dB: trackPeak in dB = trackPeak / 256 * to convert to floating [-1..1]: trackPeak = 10^(trackPeak / 256 / 20)/32768 */ - int trackPeak() const; + int trackPeak() const; - /*! + /*! * Returns the album gain as an integer value, * to convert to dB: albumGain in dB = 64.82 - (albumGain / 256) */ - int albumGain() const; + int albumGain() const; - /*! + /*! * Returns the album peak as an integer value, * to convert to dB: albumPeak in dB = albumPeak / 256 * to convert to floating [-1..1]: albumPeak = 10^(albumPeak / 256 / 20)/32768 */ - int albumPeak() const; + int albumPeak() const; - private: - Properties(const Properties &); - Properties &operator=(const Properties &); + private: + Properties(const Properties &); + Properties &operator=(const Properties &); - void readSV7(const ByteVector &data, long streamLength); - void readSV8(File *file, long streamLength); + void readSV7(const ByteVector &data, long streamLength); + void readSV8(File *file, long streamLength); - class PropertiesPrivate; - PropertiesPrivate *d; - }; - } -} -} + class PropertiesPrivate; + PropertiesPrivate *d; +}; +} // namespace MPC +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/id3v1/id3v1genres.cpp b/3rdparty/taglib/mpeg/id3v1/id3v1genres.cpp index 852757970..652e0d96a 100644 --- a/3rdparty/taglib/mpeg/id3v1/id3v1genres.cpp +++ b/3rdparty/taglib/mpeg/id3v1/id3v1genres.cpp @@ -27,237 +27,232 @@ using namespace Strawberry_TagLib::TagLib; -namespace -{ - const wchar_t *genres[] = { - L"Blues", - L"Classic Rock", - L"Country", - L"Dance", - L"Disco", - L"Funk", - L"Grunge", - L"Hip-Hop", - L"Jazz", - L"Metal", - L"New Age", - L"Oldies", - L"Other", - L"Pop", - L"R&B", - L"Rap", - L"Reggae", - L"Rock", - L"Techno", - L"Industrial", - L"Alternative", - L"Ska", - L"Death Metal", - L"Pranks", - L"Soundtrack", - L"Euro-Techno", - L"Ambient", - L"Trip-Hop", - L"Vocal", - L"Jazz+Funk", - L"Fusion", - L"Trance", - L"Classical", - L"Instrumental", - L"Acid", - L"House", - L"Game", - L"Sound Clip", - L"Gospel", - L"Noise", - L"Alternative Rock", - L"Bass", - L"Soul", - L"Punk", - L"Space", - L"Meditative", - L"Instrumental Pop", - L"Instrumental Rock", - L"Ethnic", - L"Gothic", - L"Darkwave", - L"Techno-Industrial", - L"Electronic", - L"Pop-Folk", - L"Eurodance", - L"Dream", - L"Southern Rock", - L"Comedy", - L"Cult", - L"Gangsta", - L"Top 40", - L"Christian Rap", - L"Pop/Funk", - L"Jungle", - L"Native American", - L"Cabaret", - L"New Wave", - L"Psychedelic", - L"Rave", - L"Showtunes", - L"Trailer", - L"Lo-Fi", - L"Tribal", - L"Acid Punk", - L"Acid Jazz", - L"Polka", - L"Retro", - L"Musical", - L"Rock & Roll", - L"Hard Rock", - L"Folk", - L"Folk/Rock", - L"National Folk", - L"Swing", - L"Fusion", - L"Bebob", - L"Latin", - L"Revival", - L"Celtic", - L"Bluegrass", - L"Avantgarde", - L"Gothic Rock", - L"Progressive Rock", - L"Psychedelic Rock", - L"Symphonic Rock", - L"Slow Rock", - L"Big Band", - L"Chorus", - L"Easy Listening", - L"Acoustic", - L"Humour", - L"Speech", - L"Chanson", - L"Opera", - L"Chamber Music", - L"Sonata", - L"Symphony", - L"Booty Bass", - L"Primus", - L"Porn Groove", - L"Satire", - L"Slow Jam", - L"Club", - L"Tango", - L"Samba", - L"Folklore", - L"Ballad", - L"Power Ballad", - L"Rhythmic Soul", - L"Freestyle", - L"Duet", - L"Punk Rock", - L"Drum Solo", - L"A Cappella", - L"Euro-House", - L"Dance Hall", - L"Goa", - L"Drum & Bass", - L"Club-House", - L"Hardcore", - L"Terror", - L"Indie", - L"BritPop", - L"Negerpunk", - L"Polsk Punk", - L"Beat", - L"Christian Gangsta Rap", - L"Heavy Metal", - L"Black Metal", - L"Crossover", - L"Contemporary Christian", - L"Christian Rock", - L"Merengue", - L"Salsa", - L"Thrash Metal", - L"Anime", - L"Jpop", - L"Synthpop", - L"Abstract", - L"Art Rock", - L"Baroque", - L"Bhangra", - L"Big Beat", - L"Breakbeat", - L"Chillout", - L"Downtempo", - L"Dub", - L"EBM", - L"Eclectic", - L"Electro", - L"Electroclash", - L"Emo", - L"Experimental", - L"Garage", - L"Global", - L"IDM", - L"Illbient", - L"Industro-Goth", - L"Jam Band", - L"Krautrock", - L"Leftfield", - L"Lounge", - L"Math Rock", - L"New Romantic", - L"Nu-Breakz", - L"Post-Punk", - L"Post-Rock", - L"Psytrance", - L"Shoegaze", - L"Space Rock", - L"Trop Rock", - L"World Music", - L"Neoclassical", - L"Audiobook", - L"Audio Theatre", - L"Neue Deutsche Welle", - L"Podcast", - L"Indie Rock", - L"G-Funk", - L"Dubstep", - L"Garage Rock", - L"Psybient" - }; - const int genresSize = sizeof(genres) / sizeof(genres[0]); -} +namespace { +const wchar_t *genres[] = { + L"Blues", + L"Classic Rock", + L"Country", + L"Dance", + L"Disco", + L"Funk", + L"Grunge", + L"Hip-Hop", + L"Jazz", + L"Metal", + L"New Age", + L"Oldies", + L"Other", + L"Pop", + L"R&B", + L"Rap", + L"Reggae", + L"Rock", + L"Techno", + L"Industrial", + L"Alternative", + L"Ska", + L"Death Metal", + L"Pranks", + L"Soundtrack", + L"Euro-Techno", + L"Ambient", + L"Trip-Hop", + L"Vocal", + L"Jazz+Funk", + L"Fusion", + L"Trance", + L"Classical", + L"Instrumental", + L"Acid", + L"House", + L"Game", + L"Sound Clip", + L"Gospel", + L"Noise", + L"Alternative Rock", + L"Bass", + L"Soul", + L"Punk", + L"Space", + L"Meditative", + L"Instrumental Pop", + L"Instrumental Rock", + L"Ethnic", + L"Gothic", + L"Darkwave", + L"Techno-Industrial", + L"Electronic", + L"Pop-Folk", + L"Eurodance", + L"Dream", + L"Southern Rock", + L"Comedy", + L"Cult", + L"Gangsta", + L"Top 40", + L"Christian Rap", + L"Pop/Funk", + L"Jungle", + L"Native American", + L"Cabaret", + L"New Wave", + L"Psychedelic", + L"Rave", + L"Showtunes", + L"Trailer", + L"Lo-Fi", + L"Tribal", + L"Acid Punk", + L"Acid Jazz", + L"Polka", + L"Retro", + L"Musical", + L"Rock & Roll", + L"Hard Rock", + L"Folk", + L"Folk/Rock", + L"National Folk", + L"Swing", + L"Fusion", + L"Bebob", + L"Latin", + L"Revival", + L"Celtic", + L"Bluegrass", + L"Avantgarde", + L"Gothic Rock", + L"Progressive Rock", + L"Psychedelic Rock", + L"Symphonic Rock", + L"Slow Rock", + L"Big Band", + L"Chorus", + L"Easy Listening", + L"Acoustic", + L"Humour", + L"Speech", + L"Chanson", + L"Opera", + L"Chamber Music", + L"Sonata", + L"Symphony", + L"Booty Bass", + L"Primus", + L"Porn Groove", + L"Satire", + L"Slow Jam", + L"Club", + L"Tango", + L"Samba", + L"Folklore", + L"Ballad", + L"Power Ballad", + L"Rhythmic Soul", + L"Freestyle", + L"Duet", + L"Punk Rock", + L"Drum Solo", + L"A Cappella", + L"Euro-House", + L"Dance Hall", + L"Goa", + L"Drum & Bass", + L"Club-House", + L"Hardcore", + L"Terror", + L"Indie", + L"BritPop", + L"Negerpunk", + L"Polsk Punk", + L"Beat", + L"Christian Gangsta Rap", + L"Heavy Metal", + L"Black Metal", + L"Crossover", + L"Contemporary Christian", + L"Christian Rock", + L"Merengue", + L"Salsa", + L"Thrash Metal", + L"Anime", + L"Jpop", + L"Synthpop", + L"Abstract", + L"Art Rock", + L"Baroque", + L"Bhangra", + L"Big Beat", + L"Breakbeat", + L"Chillout", + L"Downtempo", + L"Dub", + L"EBM", + L"Eclectic", + L"Electro", + L"Electroclash", + L"Emo", + L"Experimental", + L"Garage", + L"Global", + L"IDM", + L"Illbient", + L"Industro-Goth", + L"Jam Band", + L"Krautrock", + L"Leftfield", + L"Lounge", + L"Math Rock", + L"New Romantic", + L"Nu-Breakz", + L"Post-Punk", + L"Post-Rock", + L"Psytrance", + L"Shoegaze", + L"Space Rock", + L"Trop Rock", + L"World Music", + L"Neoclassical", + L"Audiobook", + L"Audio Theatre", + L"Neue Deutsche Welle", + L"Podcast", + L"Indie Rock", + L"G-Funk", + L"Dubstep", + L"Garage Rock", + L"Psybient" +}; +const int genresSize = sizeof(genres) / sizeof(genres[0]); +} // namespace -StringList ID3v1::genreList() -{ +StringList ID3v1::genreList() { StringList l; - for(int i = 0; i < genresSize; i++) { + for (int i = 0; i < genresSize; i++) { l.append(genres[i]); } return l; } -ID3v1::GenreMap ID3v1::genreMap() -{ +ID3v1::GenreMap ID3v1::genreMap() { GenreMap m; - for(int i = 0; i < genresSize; i++) { + for (int i = 0; i < genresSize; i++) { m.insert(genres[i], i); } return m; } -String ID3v1::genre(int i) -{ - if(i >= 0 && i < genresSize) - return String(genres[i]); // always make a copy +String ID3v1::genre(int i) { + if (i >= 0 && i < genresSize) + return String(genres[i]); // always make a copy else return String(); } -int ID3v1::genreIndex(const String &name) -{ - for(int i = 0; i < genresSize; ++i) { - if(name == genres[i]) +int ID3v1::genreIndex(const String &name) { + for (int i = 0; i < genresSize; ++i) { + if (name == genres[i]) return i; } diff --git a/3rdparty/taglib/mpeg/id3v1/id3v1genres.h b/3rdparty/taglib/mpeg/id3v1/id3v1genres.h index 81d26bcf5..5f8bbffa3 100644 --- a/3rdparty/taglib/mpeg/id3v1/id3v1genres.h +++ b/3rdparty/taglib/mpeg/id3v1/id3v1genres.h @@ -32,37 +32,37 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace ID3v1 { +namespace ID3v1 { - typedef Map GenreMap; +typedef Map GenreMap; - /*! +/*! * Returns the list of canonical ID3v1 genre names in the order that they * are listed in the standard. */ - StringList TAGLIB_EXPORT genreList(); +StringList TAGLIB_EXPORT genreList(); - /*! +/*! * A "reverse mapping" that goes from the canonical ID3v1 genre name to the * respective genre number. genreMap()["Rock"] == */ - GenreMap TAGLIB_EXPORT genreMap(); +GenreMap TAGLIB_EXPORT genreMap(); - /*! +/*! * Returns the name of the genre at \a index in the ID3v1 genre list. If * \a index is out of range -- less than zero or greater than 191 -- a null * string will be returned. */ - String TAGLIB_EXPORT genre(int index); +String TAGLIB_EXPORT genre(int index); - /*! +/*! * Returns the genre index for the (case sensitive) genre \a name. If the * genre is not in the list 255 (which signifies an unknown genre in ID3v1) * will be returned. */ - int TAGLIB_EXPORT genreIndex(const String &name); - } -} -} +int TAGLIB_EXPORT genreIndex(const String &name); +} // namespace ID3v1 +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/id3v1/id3v1tag.cpp b/3rdparty/taglib/mpeg/id3v1/id3v1tag.cpp index 894f2124f..78348287d 100644 --- a/3rdparty/taglib/mpeg/id3v1/id3v1tag.cpp +++ b/3rdparty/taglib/mpeg/id3v1/id3v1tag.cpp @@ -32,20 +32,17 @@ using namespace Strawberry_TagLib::TagLib; using namespace ID3v1; -namespace -{ - const ID3v1::StringHandler defaultStringHandler; - const ID3v1::StringHandler *stringHandler = &defaultStringHandler; -} +namespace { +const ID3v1::StringHandler defaultStringHandler; +const ID3v1::StringHandler *stringHandler = &defaultStringHandler; +} // namespace -class ID3v1::Tag::TagPrivate -{ -public: - TagPrivate() : - file(0), - tagOffset(0), - track(0), - genre(255) {} +class ID3v1::Tag::TagPrivate { + public: + TagPrivate() : file(0), + tagOffset(0), + track(0), + genre(255) {} File *file; long tagOffset; @@ -63,18 +60,15 @@ public: // StringHandler implementation //////////////////////////////////////////////////////////////////////////////// -StringHandler::StringHandler() -{ +StringHandler::StringHandler() { } -String ID3v1::StringHandler::parse(const ByteVector &data) const -{ +String ID3v1::StringHandler::parse(const ByteVector &data) const { return String(data, String::Latin1).stripWhiteSpace(); } -ByteVector ID3v1::StringHandler::render(const String &s) const -{ - if(s.isLatin1()) +ByteVector ID3v1::StringHandler::render(const String &s) const { + if (s.isLatin1()) return s.data(String::Latin1); else return ByteVector(); @@ -84,29 +78,23 @@ ByteVector ID3v1::StringHandler::render(const String &s) const // public methods //////////////////////////////////////////////////////////////////////////////// -ID3v1::Tag::Tag() : - Strawberry_TagLib::TagLib::Tag(), - d(new TagPrivate()) -{ +ID3v1::Tag::Tag() : Strawberry_TagLib::TagLib::Tag(), + d(new TagPrivate()) { } -ID3v1::Tag::Tag(File *file, long tagOffset) : - Strawberry_TagLib::TagLib::Tag(), - d(new TagPrivate()) -{ +ID3v1::Tag::Tag(File *file, long tagOffset) : Strawberry_TagLib::TagLib::Tag(), + d(new TagPrivate()) { d->file = file; d->tagOffset = tagOffset; read(); } -ID3v1::Tag::~Tag() -{ +ID3v1::Tag::~Tag() { delete d; } -ByteVector ID3v1::Tag::render() const -{ +ByteVector ID3v1::Tag::render() const { ByteVector data; data.append(fileIdentifier()); @@ -122,94 +110,76 @@ ByteVector ID3v1::Tag::render() const return data; } -ByteVector ID3v1::Tag::fileIdentifier() -{ +ByteVector ID3v1::Tag::fileIdentifier() { return ByteVector::fromCString("TAG"); } -String ID3v1::Tag::title() const -{ +String ID3v1::Tag::title() const { return d->title; } -String ID3v1::Tag::artist() const -{ +String ID3v1::Tag::artist() const { return d->artist; } -String ID3v1::Tag::album() const -{ +String ID3v1::Tag::album() const { return d->album; } -String ID3v1::Tag::comment() const -{ +String ID3v1::Tag::comment() const { return d->comment; } -String ID3v1::Tag::genre() const -{ +String ID3v1::Tag::genre() const { return ID3v1::genre(d->genre); } -unsigned int ID3v1::Tag::year() const -{ +unsigned int ID3v1::Tag::year() const { return d->year.toInt(); } -unsigned int ID3v1::Tag::track() const -{ +unsigned int ID3v1::Tag::track() const { return d->track; } -void ID3v1::Tag::setTitle(const String &s) -{ +void ID3v1::Tag::setTitle(const String &s) { d->title = s; } -void ID3v1::Tag::setArtist(const String &s) -{ +void ID3v1::Tag::setArtist(const String &s) { d->artist = s; } -void ID3v1::Tag::setAlbum(const String &s) -{ +void ID3v1::Tag::setAlbum(const String &s) { d->album = s; } -void ID3v1::Tag::setComment(const String &s) -{ +void ID3v1::Tag::setComment(const String &s) { d->comment = s; } -void ID3v1::Tag::setGenre(const String &s) -{ +void ID3v1::Tag::setGenre(const String &s) { d->genre = ID3v1::genreIndex(s); } -void ID3v1::Tag::setYear(unsigned int i) -{ +void ID3v1::Tag::setYear(unsigned int i) { d->year = i > 0 ? String::number(i) : String(); } -void ID3v1::Tag::setTrack(unsigned int i) -{ +void ID3v1::Tag::setTrack(unsigned int i) { d->track = i < 256 ? i : 0; } -unsigned int ID3v1::Tag::genreNumber() const -{ +unsigned int ID3v1::Tag::genreNumber() const { return d->genre; } -void ID3v1::Tag::setGenreNumber(unsigned int i) -{ +void ID3v1::Tag::setGenreNumber(unsigned int i) { d->genre = i < 256 ? i : 255; } -void ID3v1::Tag::setStringHandler(const StringHandler *handler) -{ - if(handler) +void ID3v1::Tag::setStringHandler(const StringHandler *handler) { + if (handler) stringHandler = handler; else stringHandler = &defaultStringHandler; @@ -219,23 +189,21 @@ void ID3v1::Tag::setStringHandler(const StringHandler *handler) // protected methods //////////////////////////////////////////////////////////////////////////////// -void ID3v1::Tag::read() -{ - if(d->file && d->file->isValid()) { +void ID3v1::Tag::read() { + if (d->file && d->file->isValid()) { d->file->seek(d->tagOffset); // read the tag -- always 128 bytes const ByteVector data = d->file->readBlock(128); // some initial sanity checking - if(data.size() == 128 && data.startsWith("TAG")) + if (data.size() == 128 && data.startsWith("TAG")) parse(data); else debug("ID3v1 tag is not valid or could not be read at the specified offset."); } } -void ID3v1::Tag::parse(const ByteVector &data) -{ +void ID3v1::Tag::parse(const ByteVector &data) { int offset = 3; d->title = stringHandler->parse(data.mid(offset, 30)); @@ -255,11 +223,11 @@ void ID3v1::Tag::parse(const ByteVector &data) // indicate the end of a C-String, specifically the comment string, a value of // zero must be assumed to be just that. - if(data[offset + 28] == 0 && data[offset + 29] != 0) { + if (data[offset + 28] == 0 && data[offset + 29] != 0) { // ID3v1.1 detected d->comment = stringHandler->parse(data.mid(offset, 28)); - d->track = static_cast(data[offset + 29]); + d->track = static_cast(data[offset + 29]); } else d->comment = data.mid(offset, 30); diff --git a/3rdparty/taglib/mpeg/id3v1/id3v1tag.h b/3rdparty/taglib/mpeg/id3v1/id3v1tag.h index d86f9c411..114cc408c 100644 --- a/3rdparty/taglib/mpeg/id3v1/id3v1tag.h +++ b/3rdparty/taglib/mpeg/id3v1/id3v1tag.h @@ -33,15 +33,15 @@ namespace Strawberry_TagLib { namespace TagLib { - class File; +class File; - //! An ID3v1 implementation +//! An ID3v1 implementation - namespace ID3v1 { +namespace ID3v1 { - //! A abstraction for the string to data encoding in ID3v1 tags. +//! A abstraction for the string to data encoding in ID3v1 tags. - /*! +/*! * ID3v1 should in theory always contain ISO-8859-1 (Latin1) data. In * practice it does not. TagLib by default only supports ISO-8859-1 data * in ID3v1 tags. @@ -58,20 +58,19 @@ namespace TagLib { * \see ID3v1::Tag::setStringHandler() */ - class TAGLIB_EXPORT StringHandler - { - TAGLIB_IGNORE_MISSING_DESTRUCTOR - public: - // BIC: Add virtual destructor. - StringHandler(); +class TAGLIB_EXPORT StringHandler { + TAGLIB_IGNORE_MISSING_DESTRUCTOR + public: + // BIC: Add virtual destructor. + StringHandler(); - /*! + /*! * Decode a string from \a data. The default implementation assumes that * \a data is an ISO-8859-1 (Latin1) character array. */ - virtual String parse(const ByteVector &data) const; + virtual String parse(const ByteVector &data) const; - /*! + /*! * Encode a ByteVector with the data from \a s. The default implementation * assumes that \a s is an ISO-8859-1 (Latin1) string. If the string is * does not conform to ISO-8859-1, no value is written. @@ -80,12 +79,12 @@ namespace TagLib { * instead do not write an ID3v1 tag in the case that the data is not * ISO-8859-1. */ - virtual ByteVector render(const String &s) const; - }; + virtual ByteVector render(const String &s) const; +}; - //! The main class in the ID3v1 implementation +//! The main class in the ID3v1 implementation - /*! +/*! * This is an implementation of the ID3v1 format. ID3v1 is both the simplest * and most common of tag formats but is rather limited. Because of its * pervasiveness and the way that applications have been written around the @@ -103,71 +102,70 @@ namespace TagLib { * truncation happens automatically when the tag is rendered. */ - class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag - { - public: - /*! +class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag { + public: + /*! * Create an ID3v1 tag with default values. */ - Tag(); + Tag(); - /*! + /*! * Create an ID3v1 tag and parse the data in \a file starting at * \a tagOffset. */ - Tag(File *file, long tagOffset); + Tag(File *file, long tagOffset); - /*! + /*! * Destroys this Tag instance. */ - virtual ~Tag(); + virtual ~Tag(); - /*! + /*! * Renders the in memory values to a ByteVector suitable for writing to * the file. */ - ByteVector render() const; + ByteVector render() const; - /*! + /*! * Returns the string "TAG" suitable for usage in locating the tag in a * file. */ - static ByteVector fileIdentifier(); + static ByteVector fileIdentifier(); - // Reimplementations. + // Reimplementations. - virtual String title() const; - virtual String artist() const; - virtual String album() const; - virtual String comment() const; - virtual String genre() const; - virtual unsigned int year() const; - virtual unsigned int track() const; + virtual String title() const; + virtual String artist() const; + virtual String album() const; + virtual String comment() const; + virtual String genre() const; + virtual unsigned int year() const; + virtual unsigned int track() const; - virtual void setTitle(const String &s); - virtual void setArtist(const String &s); - virtual void setAlbum(const String &s); - virtual void setComment(const String &s); - virtual void setGenre(const String &s); - virtual void setYear(unsigned int i); - virtual void setTrack(unsigned int i); + virtual void setTitle(const String &s); + virtual void setArtist(const String &s); + virtual void setAlbum(const String &s); + virtual void setComment(const String &s); + virtual void setGenre(const String &s); + virtual void setYear(unsigned int i); + virtual void setTrack(unsigned int i); - /*! + /*! * Returns the genre in number. * * \note Normally 255 indicates that this tag contains no genre. */ - unsigned int genreNumber() const; + unsigned int genreNumber() const; - /*! + /*! * Sets the genre in number to \a i. * * \note Valid value is from 0 up to 255. Normally 255 indicates that * this tag contains no genre. */ - void setGenreNumber(unsigned int i); + void setGenreNumber(unsigned int i); - /*! + /*! * Sets the string handler that decides how the ID3v1 data will be * converted to and from binary data. * If the parameter \a handler is null, the previous handler is @@ -178,27 +176,27 @@ namespace TagLib { * * \see StringHandler */ - static void setStringHandler(const StringHandler *handler); + static void setStringHandler(const StringHandler *handler); - protected: - /*! + protected: + /*! * Reads from the file specified in the constructor. */ - void read(); - /*! + void read(); + /*! * Pareses the body of the tag in \a data. */ - void parse(const ByteVector &data); + void parse(const ByteVector &data); - private: - Tag(const Tag &); - Tag &operator=(const Tag &); + private: + Tag(const Tag &); + Tag &operator=(const Tag &); - class TagPrivate; - TagPrivate *d; - }; - } -} -} + class TagPrivate; + TagPrivate *d; +}; +} // namespace ID3v1 +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/id3v2/frames/attachedpictureframe.cpp b/3rdparty/taglib/mpeg/id3v2/frames/attachedpictureframe.cpp index 4355cc766..85e44df5a 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/attachedpictureframe.cpp +++ b/3rdparty/taglib/mpeg/id3v2/frames/attachedpictureframe.cpp @@ -31,9 +31,8 @@ using namespace Strawberry_TagLib::TagLib; using namespace ID3v2; -class AttachedPictureFrame::AttachedPictureFramePrivate -{ -public: +class AttachedPictureFrame::AttachedPictureFramePrivate { + public: AttachedPictureFramePrivate() : textEncoding(String::Latin1), type(AttachedPictureFrame::Other) {} @@ -48,77 +47,61 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -AttachedPictureFrame::AttachedPictureFrame() : - Frame("APIC"), - d(new AttachedPictureFramePrivate()) -{ +AttachedPictureFrame::AttachedPictureFrame() : Frame("APIC"), + d(new AttachedPictureFramePrivate()) { } -AttachedPictureFrame::AttachedPictureFrame(const ByteVector &data) : - Frame(data), - d(new AttachedPictureFramePrivate()) -{ +AttachedPictureFrame::AttachedPictureFrame(const ByteVector &data) : Frame(data), + d(new AttachedPictureFramePrivate()) { setData(data); } -AttachedPictureFrame::~AttachedPictureFrame() -{ +AttachedPictureFrame::~AttachedPictureFrame() { delete d; } -String AttachedPictureFrame::toString() const -{ +String AttachedPictureFrame::toString() const { String s = "[" + d->mimeType + "]"; return d->description.isEmpty() ? s : d->description + " " + s; } -String::Type AttachedPictureFrame::textEncoding() const -{ +String::Type AttachedPictureFrame::textEncoding() const { return d->textEncoding; } -void AttachedPictureFrame::setTextEncoding(String::Type t) -{ +void AttachedPictureFrame::setTextEncoding(String::Type t) { d->textEncoding = t; } -String AttachedPictureFrame::mimeType() const -{ +String AttachedPictureFrame::mimeType() const { return d->mimeType; } -void AttachedPictureFrame::setMimeType(const String &m) -{ +void AttachedPictureFrame::setMimeType(const String &m) { d->mimeType = m; } -AttachedPictureFrame::Type AttachedPictureFrame::type() const -{ +AttachedPictureFrame::Type AttachedPictureFrame::type() const { return d->type; } -void AttachedPictureFrame::setType(Type t) -{ +void AttachedPictureFrame::setType(Type t) { d->type = t; } -String AttachedPictureFrame::description() const -{ +String AttachedPictureFrame::description() const { return d->description; } -void AttachedPictureFrame::setDescription(const String &desc) -{ +void AttachedPictureFrame::setDescription(const String &desc) { d->description = desc; } -ByteVector AttachedPictureFrame::picture() const -{ +ByteVector AttachedPictureFrame::picture() const { return d->data; } -void AttachedPictureFrame::setPicture(const ByteVector &p) -{ +void AttachedPictureFrame::setPicture(const ByteVector &p) { d->data = p; } @@ -126,9 +109,8 @@ void AttachedPictureFrame::setPicture(const ByteVector &p) // protected members //////////////////////////////////////////////////////////////////////////////// -void AttachedPictureFrame::parseFields(const ByteVector &data) -{ - if(data.size() < 5) { +void AttachedPictureFrame::parseFields(const ByteVector &data) { + if (data.size() < 5) { debug("A picture frame must contain at least 5 bytes."); return; } @@ -139,7 +121,7 @@ void AttachedPictureFrame::parseFields(const ByteVector &data) d->mimeType = readStringField(data, String::Latin1, &pos); /* Now we need at least two more bytes available */ - if(static_cast(pos) + 1 >= data.size()) { + if (static_cast(pos) + 1 >= data.size()) { debug("Truncated picture frame."); return; } @@ -150,8 +132,7 @@ void AttachedPictureFrame::parseFields(const ByteVector &data) d->data = data.mid(pos); } -ByteVector AttachedPictureFrame::renderFields() const -{ +ByteVector AttachedPictureFrame::renderFields() const { ByteVector data; String::Type encoding = checkTextEncoding(d->description, d->textEncoding); @@ -171,10 +152,8 @@ ByteVector AttachedPictureFrame::renderFields() const // private members //////////////////////////////////////////////////////////////////////////////// -AttachedPictureFrame::AttachedPictureFrame(const ByteVector &data, Header *h) : - Frame(h), - d(new AttachedPictureFramePrivate()) -{ +AttachedPictureFrame::AttachedPictureFrame(const ByteVector &data, Header *h) : Frame(h), + d(new AttachedPictureFramePrivate()) { parseFields(fieldData(data)); } @@ -182,9 +161,8 @@ AttachedPictureFrame::AttachedPictureFrame(const ByteVector &data, Header *h) : // support for ID3v2.2 PIC frames //////////////////////////////////////////////////////////////////////////////// -void AttachedPictureFrameV22::parseFields(const ByteVector &data) -{ - if(data.size() < 5) { +void AttachedPictureFrameV22::parseFields(const ByteVector &data) { + if (data.size() < 5) { debug("A picture frame must contain at least 5 bytes."); return; } @@ -198,9 +176,11 @@ void AttachedPictureFrameV22::parseFields(const ByteVector &data) // convert fixed string image type to mime string if (fixedString.upper() == "JPG") { d->mimeType = "image/jpeg"; - } else if (fixedString.upper() == "PNG") { + } + else if (fixedString.upper() == "PNG") { d->mimeType = "image/png"; - } else { + } + else { debug("probably unsupported image type"); d->mimeType = "image/" + fixedString; } @@ -211,8 +191,7 @@ void AttachedPictureFrameV22::parseFields(const ByteVector &data) d->data = data.mid(pos); } -AttachedPictureFrameV22::AttachedPictureFrameV22(const ByteVector &data, Header *h) -{ +AttachedPictureFrameV22::AttachedPictureFrameV22(const ByteVector &data, Header *h) { // set v2.2 header to make fieldData work correctly setHeader(h, true); diff --git a/3rdparty/taglib/mpeg/id3v2/frames/attachedpictureframe.h b/3rdparty/taglib/mpeg/id3v2/frames/attachedpictureframe.h index f7396c8d2..be5e314dd 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/attachedpictureframe.h +++ b/3rdparty/taglib/mpeg/id3v2/frames/attachedpictureframe.h @@ -33,136 +33,134 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace ID3v2 { +namespace ID3v2 { - //! An ID3v2 attached picture frame implementation +//! An ID3v2 attached picture frame implementation - /*! +/*! * This is an implementation of ID3v2 attached pictures. Pictures may be * included in tags, one per APIC frame (but there may be multiple APIC * frames in a single tag). These pictures are usually in either JPEG or * PNG format. */ - class TAGLIB_EXPORT AttachedPictureFrame : public Frame - { - friend class FrameFactory; +class TAGLIB_EXPORT AttachedPictureFrame : public Frame { + friend class FrameFactory; - public: - - /*! + public: + /*! * This describes the function or content of the picture. */ - enum Type { - //! A type not enumerated below - Other = 0x00, - //! 32x32 PNG image that should be used as the file icon - FileIcon = 0x01, - //! File icon of a different size or format - OtherFileIcon = 0x02, - //! Front cover image of the album - FrontCover = 0x03, - //! Back cover image of the album - BackCover = 0x04, - //! Inside leaflet page of the album - LeafletPage = 0x05, - //! Image from the album itself - Media = 0x06, - //! Picture of the lead artist or soloist - LeadArtist = 0x07, - //! Picture of the artist or performer - Artist = 0x08, - //! Picture of the conductor - Conductor = 0x09, - //! Picture of the band or orchestra - Band = 0x0A, - //! Picture of the composer - Composer = 0x0B, - //! Picture of the lyricist or text writer - Lyricist = 0x0C, - //! Picture of the recording location or studio - RecordingLocation = 0x0D, - //! Picture of the artists during recording - DuringRecording = 0x0E, - //! Picture of the artists during performance - DuringPerformance = 0x0F, - //! Picture from a movie or video related to the track - MovieScreenCapture = 0x10, - //! Picture of a large, coloured fish - ColouredFish = 0x11, - //! Illustration related to the track - Illustration = 0x12, - //! Logo of the band or performer - BandLogo = 0x13, - //! Logo of the publisher (record company) - PublisherLogo = 0x14 - }; + enum Type { + //! A type not enumerated below + Other = 0x00, + //! 32x32 PNG image that should be used as the file icon + FileIcon = 0x01, + //! File icon of a different size or format + OtherFileIcon = 0x02, + //! Front cover image of the album + FrontCover = 0x03, + //! Back cover image of the album + BackCover = 0x04, + //! Inside leaflet page of the album + LeafletPage = 0x05, + //! Image from the album itself + Media = 0x06, + //! Picture of the lead artist or soloist + LeadArtist = 0x07, + //! Picture of the artist or performer + Artist = 0x08, + //! Picture of the conductor + Conductor = 0x09, + //! Picture of the band or orchestra + Band = 0x0A, + //! Picture of the composer + Composer = 0x0B, + //! Picture of the lyricist or text writer + Lyricist = 0x0C, + //! Picture of the recording location or studio + RecordingLocation = 0x0D, + //! Picture of the artists during recording + DuringRecording = 0x0E, + //! Picture of the artists during performance + DuringPerformance = 0x0F, + //! Picture from a movie or video related to the track + MovieScreenCapture = 0x10, + //! Picture of a large, coloured fish + ColouredFish = 0x11, + //! Illustration related to the track + Illustration = 0x12, + //! Logo of the band or performer + BandLogo = 0x13, + //! Logo of the publisher (record company) + PublisherLogo = 0x14 + }; - /*! + /*! * Constructs an empty picture frame. The description, content and text * encoding should be set manually. */ - AttachedPictureFrame(); + AttachedPictureFrame(); - /*! + /*! * Constructs an AttachedPicture frame based on \a data. */ - explicit AttachedPictureFrame(const ByteVector &data); + explicit AttachedPictureFrame(const ByteVector &data); - /*! + /*! * Destroys the AttahcedPictureFrame instance. */ - virtual ~AttachedPictureFrame(); + virtual ~AttachedPictureFrame(); - /*! + /*! * Returns a string containing the description and mime-type */ - virtual String toString() const; + virtual String toString() const; - /*! + /*! * Returns the text encoding used for the description. * * \see setTextEncoding() * \see description() */ - String::Type textEncoding() const; + String::Type textEncoding() const; - /*! + /*! * Set the text encoding used for the description. * * \see description() */ - void setTextEncoding(String::Type t); + void setTextEncoding(String::Type t); - /*! + /*! * Returns the mime type of the image. This should in most cases be * "image/png" or "image/jpeg". */ - String mimeType() const; + String mimeType() const; - /*! + /*! * Sets the mime type of the image. This should in most cases be * "image/png" or "image/jpeg". */ - void setMimeType(const String &m); + void setMimeType(const String &m); - /*! + /*! * Returns the type of the image. * * \see Type * \see setType() */ - Type type() const; + Type type() const; - /*! + /*! * Sets the type for the image. * * \see Type * \see type() */ - void setType(Type t); + void setType(Type t); - /*! + /*! * Returns a text description of the image. * * \see setDescription() @@ -170,9 +168,9 @@ namespace TagLib { * \see setTextEncoding() */ - String description() const; + String description() const; - /*! + /*! * Sets a textual description of the image to \a desc. * * \see description() @@ -180,9 +178,9 @@ namespace TagLib { * \see setTextEncoding() */ - void setDescription(const String &desc); + void setDescription(const String &desc); - /*! + /*! * Returns the image data as a ByteVector. * * \note ByteVector has a data() method that returns a const char * which @@ -191,9 +189,9 @@ namespace TagLib { * \see setPicture() * \see mimeType() */ - ByteVector picture() const; + ByteVector picture() const; - /*! + /*! * Sets the image data to \a p. \a p should be of the type specified in * this frame's mime-type specification. * @@ -201,32 +199,31 @@ namespace TagLib { * \see mimeType() * \see setMimeType() */ - void setPicture(const ByteVector &p); + void setPicture(const ByteVector &p); - protected: - virtual void parseFields(const ByteVector &data); - virtual ByteVector renderFields() const; - class AttachedPictureFramePrivate; - AttachedPictureFramePrivate *d; + protected: + virtual void parseFields(const ByteVector &data); + virtual ByteVector renderFields() const; + class AttachedPictureFramePrivate; + AttachedPictureFramePrivate *d; - private: - AttachedPictureFrame(const AttachedPictureFrame &); - AttachedPictureFrame &operator=(const AttachedPictureFrame &); - AttachedPictureFrame(const ByteVector &data, Header *h); + private: + AttachedPictureFrame(const AttachedPictureFrame &); + AttachedPictureFrame &operator=(const AttachedPictureFrame &); + AttachedPictureFrame(const ByteVector &data, Header *h); +}; - }; +//! support for ID3v2.2 PIC frames +class TAGLIB_EXPORT AttachedPictureFrameV22 : public AttachedPictureFrame { + protected: + virtual void parseFields(const ByteVector &data); - //! support for ID3v2.2 PIC frames - class TAGLIB_EXPORT AttachedPictureFrameV22 : public AttachedPictureFrame - { - protected: - virtual void parseFields(const ByteVector &data); - private: - AttachedPictureFrameV22(const ByteVector &data, Header *h); - friend class FrameFactory; - }; - } -} -} + private: + AttachedPictureFrameV22(const ByteVector &data, Header *h); + friend class FrameFactory; +}; +} // namespace ID3v2 +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/id3v2/frames/chapterframe.cpp b/3rdparty/taglib/mpeg/id3v2/frames/chapterframe.cpp index b7103a8b5..37498ace3 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/chapterframe.cpp +++ b/3rdparty/taglib/mpeg/id3v2/frames/chapterframe.cpp @@ -33,16 +33,13 @@ using namespace Strawberry_TagLib::TagLib; using namespace ID3v2; -class ChapterFrame::ChapterFramePrivate -{ -public: - ChapterFramePrivate() : - tagHeader(0), - startTime(0), - endTime(0), - startOffset(0), - endOffset(0) - { +class ChapterFrame::ChapterFramePrivate { + public: + ChapterFramePrivate() : tagHeader(0), + startTime(0), + endTime(0), + startOffset(0), + endOffset(0) { embeddedFrameList.setAutoDelete(true); } @@ -60,21 +57,17 @@ public: // public methods //////////////////////////////////////////////////////////////////////////////// -ChapterFrame::ChapterFrame(const ID3v2::Header *tagHeader, const ByteVector &data) : - ID3v2::Frame(data), - d(new ChapterFramePrivate()) -{ +ChapterFrame::ChapterFrame(const ID3v2::Header *tagHeader, const ByteVector &data) : ID3v2::Frame(data), + d(new ChapterFramePrivate()) { d->tagHeader = tagHeader; setData(data); } ChapterFrame::ChapterFrame(const ByteVector &elementID, - unsigned int startTime, unsigned int endTime, - unsigned int startOffset, unsigned int endOffset, - const FrameList &embeddedFrames) : - ID3v2::Frame("CHAP"), - d(new ChapterFramePrivate()) -{ + unsigned int startTime, unsigned int endTime, + unsigned int startOffset, unsigned int endOffset, + const FrameList &embeddedFrames) : ID3v2::Frame("CHAP"), + d(new ChapterFramePrivate()) { // setElementID has a workaround for a previously silly API where you had to // specifically include the null byte. @@ -85,92 +78,77 @@ ChapterFrame::ChapterFrame(const ByteVector &elementID, d->startOffset = startOffset; d->endOffset = endOffset; - for(FrameList::ConstIterator it = embeddedFrames.begin(); - it != embeddedFrames.end(); ++it) + for (FrameList::ConstIterator it = embeddedFrames.begin(); + it != embeddedFrames.end(); + ++it) addEmbeddedFrame(*it); } -ChapterFrame::~ChapterFrame() -{ +ChapterFrame::~ChapterFrame() { delete d; } -ByteVector ChapterFrame::elementID() const -{ +ByteVector ChapterFrame::elementID() const { return d->elementID; } -unsigned int ChapterFrame::startTime() const -{ +unsigned int ChapterFrame::startTime() const { return d->startTime; } -unsigned int ChapterFrame::endTime() const -{ +unsigned int ChapterFrame::endTime() const { return d->endTime; } -unsigned int ChapterFrame::startOffset() const -{ +unsigned int ChapterFrame::startOffset() const { return d->startOffset; } -unsigned int ChapterFrame::endOffset() const -{ +unsigned int ChapterFrame::endOffset() const { return d->endOffset; } -void ChapterFrame::setElementID(const ByteVector &eID) -{ +void ChapterFrame::setElementID(const ByteVector &eID) { d->elementID = eID; - if(d->elementID.endsWith(char(0))) + if (d->elementID.endsWith(char(0))) d->elementID = d->elementID.mid(0, d->elementID.size() - 1); } -void ChapterFrame::setStartTime(const unsigned int &sT) -{ +void ChapterFrame::setStartTime(const unsigned int &sT) { d->startTime = sT; } -void ChapterFrame::setEndTime(const unsigned int &eT) -{ +void ChapterFrame::setEndTime(const unsigned int &eT) { d->endTime = eT; } -void ChapterFrame::setStartOffset(const unsigned int &sO) -{ +void ChapterFrame::setStartOffset(const unsigned int &sO) { d->startOffset = sO; } -void ChapterFrame::setEndOffset(const unsigned int &eO) -{ +void ChapterFrame::setEndOffset(const unsigned int &eO) { d->endOffset = eO; } -const FrameListMap &ChapterFrame::embeddedFrameListMap() const -{ +const FrameListMap &ChapterFrame::embeddedFrameListMap() const { return d->embeddedFrameListMap; } -const FrameList &ChapterFrame::embeddedFrameList() const -{ +const FrameList &ChapterFrame::embeddedFrameList() const { return d->embeddedFrameList; } -const FrameList &ChapterFrame::embeddedFrameList(const ByteVector &frameID) const -{ +const FrameList &ChapterFrame::embeddedFrameList(const ByteVector &frameID) const { return d->embeddedFrameListMap[frameID]; } -void ChapterFrame::addEmbeddedFrame(Frame *frame) -{ +void ChapterFrame::addEmbeddedFrame(Frame *frame) { d->embeddedFrameList.append(frame); d->embeddedFrameListMap[frame->frameID()].append(frame); } -void ChapterFrame::removeEmbeddedFrame(Frame *frame, bool del) -{ +void ChapterFrame::removeEmbeddedFrame(Frame *frame, bool del) { // remove the frame from the frame list FrameList::Iterator it = d->embeddedFrameList.find(frame); d->embeddedFrameList.erase(it); @@ -180,33 +158,32 @@ void ChapterFrame::removeEmbeddedFrame(Frame *frame, bool del) d->embeddedFrameListMap[frame->frameID()].erase(it); // ...and delete as desired - if(del) + if (del) delete frame; } -void ChapterFrame::removeEmbeddedFrames(const ByteVector &id) -{ +void ChapterFrame::removeEmbeddedFrames(const ByteVector &id) { FrameList l = d->embeddedFrameListMap[id]; - for(FrameList::ConstIterator it = l.begin(); it != l.end(); ++it) + for (FrameList::ConstIterator it = l.begin(); it != l.end(); ++it) removeEmbeddedFrame(*it, true); } -String ChapterFrame::toString() const -{ +String ChapterFrame::toString() const { String s = String(d->elementID) + - ": start time: " + String::number(d->startTime) + - ", end time: " + String::number(d->endTime); + ": start time: " + String::number(d->startTime) + + ", end time: " + String::number(d->endTime); - if(d->startOffset != 0xFFFFFFFF) + if (d->startOffset != 0xFFFFFFFF) s += ", start offset: " + String::number(d->startOffset); - if(d->endOffset != 0xFFFFFFFF) + if (d->endOffset != 0xFFFFFFFF) s += ", end offset: " + String::number(d->endOffset); - if(!d->embeddedFrameList.isEmpty()) { + if (!d->embeddedFrameList.isEmpty()) { StringList frameIDs; - for(FrameList::ConstIterator it = d->embeddedFrameList.begin(); - it != d->embeddedFrameList.end(); ++it) + for (FrameList::ConstIterator it = d->embeddedFrameList.begin(); + it != d->embeddedFrameList.end(); + ++it) frameIDs.append((*it)->frameID()); s += ", sub-frames: [ " + frameIDs.toString(", ") + " ]"; } @@ -214,8 +191,7 @@ String ChapterFrame::toString() const return s; } -PropertyMap ChapterFrame::asProperties() const -{ +PropertyMap ChapterFrame::asProperties() const { PropertyMap map; map.unsupportedData().append(frameID() + String("/") + d->elementID); @@ -223,26 +199,24 @@ PropertyMap ChapterFrame::asProperties() const return map; } -ChapterFrame *ChapterFrame::findByElementID(const ID3v2::Tag *tag, const ByteVector &eID) // static +ChapterFrame *ChapterFrame::findByElementID(const ID3v2::Tag *tag, const ByteVector &eID) // static { ID3v2::FrameList comments = tag->frameList("CHAP"); - for(ID3v2::FrameList::ConstIterator it = comments.begin(); - it != comments.end(); - ++it) - { + for (ID3v2::FrameList::ConstIterator it = comments.begin(); + it != comments.end(); + ++it) { ChapterFrame *frame = dynamic_cast(*it); - if(frame && frame->elementID() == eID) + if (frame && frame->elementID() == eID) return frame; } return nullptr; } -void ChapterFrame::parseFields(const ByteVector &data) -{ +void ChapterFrame::parseFields(const ByteVector &data) { unsigned int size = data.size(); - if(size < 18) { + if (size < 18) { debug("A CHAP frame must contain at least 18 bytes (1 byte element ID " "terminated by null and 4x4 bytes for start and end time and offset)."); return; @@ -263,17 +237,17 @@ void ChapterFrame::parseFields(const ByteVector &data) // Embedded frames are optional - if(size < header()->size()) + if (size < header()->size()) return; - while(embPos < size - header()->size()) { + while (embPos < size - header()->size()) { Frame *frame = FrameFactory::instance()->createFrame(data.mid(pos + embPos), d->tagHeader); - if(!frame) + if (!frame) return; // Checks to make sure that frame parsed correctly. - if(frame->size() <= 0) { + if (frame->size() <= 0) { delete frame; return; } @@ -283,8 +257,7 @@ void ChapterFrame::parseFields(const ByteVector &data) } } -ByteVector ChapterFrame::renderFields() const -{ +ByteVector ChapterFrame::renderFields() const { ByteVector data; data.append(d->elementID); @@ -294,16 +267,14 @@ ByteVector ChapterFrame::renderFields() const data.append(ByteVector::fromUInt(d->startOffset, true)); data.append(ByteVector::fromUInt(d->endOffset, true)); FrameList l = d->embeddedFrameList; - for(FrameList::ConstIterator it = l.begin(); it != l.end(); ++it) + for (FrameList::ConstIterator it = l.begin(); it != l.end(); ++it) data.append((*it)->render()); return data; } -ChapterFrame::ChapterFrame(const ID3v2::Header *tagHeader, const ByteVector &data, Header *h) : - Frame(h), - d(new ChapterFramePrivate()) -{ +ChapterFrame::ChapterFrame(const ID3v2::Header *tagHeader, const ByteVector &data, Header *h) : Frame(h), + d(new ChapterFramePrivate()) { d->tagHeader = tagHeader; parseFields(fieldData(data)); } diff --git a/3rdparty/taglib/mpeg/id3v2/frames/chapterframe.h b/3rdparty/taglib/mpeg/id3v2/frames/chapterframe.h index 6bf7ab415..3ea060385 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/chapterframe.h +++ b/3rdparty/taglib/mpeg/id3v2/frames/chapterframe.h @@ -33,27 +33,26 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace ID3v2 { +namespace ID3v2 { - /*! +/*! * This is an implementation of ID3v2 chapter frames. The purpose of this * frame is to describe a single chapter within an audio file. */ - //! An implementation of ID3v2 chapter frames +//! An implementation of ID3v2 chapter frames - class TAGLIB_EXPORT ChapterFrame : public ID3v2::Frame - { - friend class FrameFactory; +class TAGLIB_EXPORT ChapterFrame : public ID3v2::Frame { + friend class FrameFactory; - public: - /*! + public: + /*! * Creates a chapter frame based on \a data. \a tagHeader is required as * the internal frames are parsed based on the tag version. */ - ChapterFrame(const ID3v2::Header *tagHeader, const ByteVector &data); + ChapterFrame(const ID3v2::Header *tagHeader, const ByteVector &data); - /*! + /*! * Creates a chapter frame with the element ID \a elementID, start time * \a startTime, end time \a endTime, start offset \a startOffset, * end offset \a endOffset and optionally a list of embedded frames, @@ -62,95 +61,95 @@ namespace TagLib { * * All times are in milliseconds. */ - ChapterFrame(const ByteVector &elementID, - unsigned int startTime, unsigned int endTime, - unsigned int startOffset, unsigned int endOffset, - const FrameList &embeddedFrames = FrameList()); + ChapterFrame(const ByteVector &elementID, + unsigned int startTime, unsigned int endTime, + unsigned int startOffset, unsigned int endOffset, + const FrameList &embeddedFrames = FrameList()); - /*! + /*! * Destroys the frame. */ - virtual ~ChapterFrame(); + virtual ~ChapterFrame(); - /*! + /*! * Returns the element ID of the frame. Element ID * is a null terminated string, however it's not human-readable. * * \see setElementID() */ - ByteVector elementID() const; + ByteVector elementID() const; - /*! + /*! * Returns time of chapter's start (in milliseconds). * * \see setStartTime() */ - unsigned int startTime() const; + unsigned int startTime() const; - /*! + /*! * Returns time of chapter's end (in milliseconds). * * \see setEndTime() */ - unsigned int endTime() const; + unsigned int endTime() const; - /*! + /*! * Returns zero based byte offset (count of bytes from the beginning * of the audio file) of chapter's start. * * \note If returned value is 0xFFFFFFFF, start time should be used instead. * \see setStartOffset() */ - unsigned int startOffset() const; + unsigned int startOffset() const; - /*! + /*! * Returns zero based byte offset (count of bytes from the beginning * of the audio file) of chapter's end. * * \note If returned value is 0xFFFFFFFF, end time should be used instead. * \see setEndOffset() */ - unsigned int endOffset() const; + unsigned int endOffset() const; - /*! + /*! * Sets the element ID of the frame to \a eID. If \a eID isn't * null terminated, a null char is appended automatically. * * \see elementID() */ - void setElementID(const ByteVector &eID); + void setElementID(const ByteVector &eID); - /*! + /*! * Sets time of chapter's start (in milliseconds) to \a sT. * * \see startTime() */ - void setStartTime(const unsigned int &sT); + void setStartTime(const unsigned int &sT); - /*! + /*! * Sets time of chapter's end (in milliseconds) to \a eT. * * \see endTime() */ - void setEndTime(const unsigned int &eT); + void setEndTime(const unsigned int &eT); - /*! + /*! * Sets zero based byte offset (count of bytes from the beginning * of the audio file) of chapter's start to \a sO. * * \see startOffset() */ - void setStartOffset(const unsigned int &sO); + void setStartOffset(const unsigned int &sO); - /*! + /*! * Sets zero based byte offset (count of bytes from the beginning * of the audio file) of chapter's end to \a eO. * * \see endOffset() */ - void setEndOffset(const unsigned int &eO); + void setEndOffset(const unsigned int &eO); - /*! + /*! * Returns a reference to the frame list map. This is an FrameListMap of * all of the frames embedded in the CHAP frame. * @@ -164,9 +163,9 @@ namespace TagLib { * * \see embeddedFrameList() */ - const FrameListMap &embeddedFrameListMap() const; + const FrameListMap &embeddedFrameListMap() const; - /*! + /*! * Returns a reference to the embedded frame list. This is an FrameList * of all of the frames embedded in the CHAP frame in the order that they * were parsed. @@ -177,9 +176,9 @@ namespace TagLib { * \warning You should not modify this data structure directly, instead * use addEmbeddedFrame() and removeEmbeddedFrame(). */ - const FrameList &embeddedFrameList() const; + const FrameList &embeddedFrameList() const; - /*! + /*! * Returns the embedded frame list for frames with the id \a frameID * or an empty list if there are no embedded frames of that type. This * is just a convenience and is equivalent to: @@ -190,62 +189,62 @@ namespace TagLib { * * \see embeddedFrameListMap() */ - const FrameList &embeddedFrameList(const ByteVector &frameID) const; + const FrameList &embeddedFrameList(const ByteVector &frameID) const; - /*! + /*! * Add an embedded frame to the CHAP frame. At this point the CHAP frame * takes ownership of the embedded frame and will handle freeing its memory. * * \note Using this method will invalidate any pointers on the list * returned by embeddedFrameList() */ - void addEmbeddedFrame(Frame *frame); + void addEmbeddedFrame(Frame *frame); - /*! + /*! * Remove an embedded frame from the CHAP frame. If \a del is true the frame's * memory will be freed; if it is false, it must be deleted by the user. * * \note Using this method will invalidate any pointers on the list * returned by embeddedFrameList() */ - void removeEmbeddedFrame(Frame *frame, bool del = true); + void removeEmbeddedFrame(Frame *frame, bool del = true); - /*! + /*! * Remove all embedded frames of type \a id from the CHAP frame and free their * memory. * * \note Using this method will invalidate any pointers on the list * returned by embeddedFrameList() */ - void removeEmbeddedFrames(const ByteVector &id); + void removeEmbeddedFrames(const ByteVector &id); - virtual String toString() const; + virtual String toString() const; - PropertyMap asProperties() const; + PropertyMap asProperties() const; - /*! + /*! * CHAP frames each have a unique element ID. This searches for a CHAP * frame with the element ID \a eID and returns a pointer to it. This * can be used to link CTOC and CHAP frames together. * * \see elementID() */ - static ChapterFrame *findByElementID(const Tag *tag, const ByteVector &eID); + static ChapterFrame *findByElementID(const Tag *tag, const ByteVector &eID); - protected: - virtual void parseFields(const ByteVector &data); - virtual ByteVector renderFields() const; + protected: + virtual void parseFields(const ByteVector &data); + virtual ByteVector renderFields() const; - private: - ChapterFrame(const ID3v2::Header *tagHeader, const ByteVector &data, Header *h); - ChapterFrame(const ChapterFrame &); - ChapterFrame &operator=(const ChapterFrame &); + private: + ChapterFrame(const ID3v2::Header *tagHeader, const ByteVector &data, Header *h); + ChapterFrame(const ChapterFrame &); + ChapterFrame &operator=(const ChapterFrame &); - class ChapterFramePrivate; - ChapterFramePrivate *d; - }; - } -} -} + class ChapterFramePrivate; + ChapterFramePrivate *d; +}; +} // namespace ID3v2 +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/id3v2/frames/commentsframe.cpp b/3rdparty/taglib/mpeg/id3v2/frames/commentsframe.cpp index 288a307e4..03cafec61 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/commentsframe.cpp +++ b/3rdparty/taglib/mpeg/id3v2/frames/commentsframe.cpp @@ -34,9 +34,8 @@ using namespace Strawberry_TagLib::TagLib; using namespace ID3v2; -class CommentsFrame::CommentsFramePrivate -{ -public: +class CommentsFrame::CommentsFramePrivate { + public: CommentsFramePrivate() : textEncoding(String::Latin1) {} String::Type textEncoding; ByteVector language; @@ -48,91 +47,75 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -CommentsFrame::CommentsFrame(String::Type encoding) : - Frame("COMM"), - d(new CommentsFramePrivate()) -{ +CommentsFrame::CommentsFrame(String::Type encoding) : Frame("COMM"), + d(new CommentsFramePrivate()) { d->textEncoding = encoding; } -CommentsFrame::CommentsFrame(const ByteVector &data) : - Frame(data), - d(new CommentsFramePrivate()) -{ +CommentsFrame::CommentsFrame(const ByteVector &data) : Frame(data), + d(new CommentsFramePrivate()) { setData(data); } -CommentsFrame::~CommentsFrame() -{ +CommentsFrame::~CommentsFrame() { delete d; } -String CommentsFrame::toString() const -{ +String CommentsFrame::toString() const { return d->text; } -ByteVector CommentsFrame::language() const -{ +ByteVector CommentsFrame::language() const { return d->language; } -String CommentsFrame::description() const -{ +String CommentsFrame::description() const { return d->description; } -String CommentsFrame::text() const -{ +String CommentsFrame::text() const { return d->text; } -void CommentsFrame::setLanguage(const ByteVector &languageEncoding) -{ +void CommentsFrame::setLanguage(const ByteVector &languageEncoding) { d->language = languageEncoding.mid(0, 3); } -void CommentsFrame::setDescription(const String &s) -{ +void CommentsFrame::setDescription(const String &s) { d->description = s; } -void CommentsFrame::setText(const String &s) -{ +void CommentsFrame::setText(const String &s) { d->text = s; } -String::Type CommentsFrame::textEncoding() const -{ +String::Type CommentsFrame::textEncoding() const { return d->textEncoding; } -void CommentsFrame::setTextEncoding(String::Type encoding) -{ +void CommentsFrame::setTextEncoding(String::Type encoding) { d->textEncoding = encoding; } -PropertyMap CommentsFrame::asProperties() const -{ +PropertyMap CommentsFrame::asProperties() const { String key = description().upper(); PropertyMap map; - if(key.isEmpty() || key == "COMMENT") + if (key.isEmpty() || key == "COMMENT") map.insert("COMMENT", text()); else map.insert("COMMENT:" + key, text()); return map; } -CommentsFrame *CommentsFrame::findByDescription(const ID3v2::Tag *tag, const String &d) // static +CommentsFrame *CommentsFrame::findByDescription(const ID3v2::Tag *tag, const String &d) // static { ID3v2::FrameList comments = tag->frameList("COMM"); - for(ID3v2::FrameList::ConstIterator it = comments.begin(); - it != comments.end(); - ++it) - { + for (ID3v2::FrameList::ConstIterator it = comments.begin(); + it != comments.end(); + ++it) { CommentsFrame *frame = dynamic_cast(*it); - if(frame && frame->description() == d) + if (frame && frame->description() == d) return frame; } @@ -143,9 +126,8 @@ CommentsFrame *CommentsFrame::findByDescription(const ID3v2::Tag *tag, const Str // protected members //////////////////////////////////////////////////////////////////////////////// -void CommentsFrame::parseFields(const ByteVector &data) -{ - if(data.size() < 5) { +void CommentsFrame::parseFields(const ByteVector &data) { + if (data.size() < 5) { debug("A comment frame must contain at least 5 bytes."); return; } @@ -157,19 +139,19 @@ void CommentsFrame::parseFields(const ByteVector &data) ByteVectorList l = ByteVectorList::split(data.mid(4), textDelimiter(d->textEncoding), byteAlign, 2); - if(l.size() == 2) { - if(d->textEncoding == String::Latin1) { + if (l.size() == 2) { + if (d->textEncoding == String::Latin1) { d->description = Tag::latin1StringHandler()->parse(l.front()); d->text = Tag::latin1StringHandler()->parse(l.back()); - } else { + } + else { d->description = String(l.front(), d->textEncoding); d->text = String(l.back(), d->textEncoding); } } } -ByteVector CommentsFrame::renderFields() const -{ +ByteVector CommentsFrame::renderFields() const { ByteVector v; String::Type encoding = d->textEncoding; @@ -190,9 +172,7 @@ ByteVector CommentsFrame::renderFields() const // private members //////////////////////////////////////////////////////////////////////////////// -CommentsFrame::CommentsFrame(const ByteVector &data, Header *h) : - Frame(h), - d(new CommentsFramePrivate()) -{ +CommentsFrame::CommentsFrame(const ByteVector &data, Header *h) : Frame(h), + d(new CommentsFramePrivate()) { parseFields(fieldData(data)); } diff --git a/3rdparty/taglib/mpeg/id3v2/frames/commentsframe.h b/3rdparty/taglib/mpeg/id3v2/frames/commentsframe.h index 02add8b75..e753c07d7 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/commentsframe.h +++ b/3rdparty/taglib/mpeg/id3v2/frames/commentsframe.h @@ -32,44 +32,43 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace ID3v2 { +namespace ID3v2 { - //! An implementation of ID3v2 comments +//! An implementation of ID3v2 comments - /*! +/*! * This implements the ID3v2 comment format. An ID3v2 comment consists of * a language encoding, a description and a single text field. */ - class TAGLIB_EXPORT CommentsFrame : public Frame - { - friend class FrameFactory; +class TAGLIB_EXPORT CommentsFrame : public Frame { + friend class FrameFactory; - public: - /*! + public: + /*! * Construct an empty comment frame that will use the text encoding * \a encoding. */ - explicit CommentsFrame(String::Type encoding = String::Latin1); + explicit CommentsFrame(String::Type encoding = String::Latin1); - /*! + /*! * Construct a comment based on the data in \a data. */ - explicit CommentsFrame(const ByteVector &data); + explicit CommentsFrame(const ByteVector &data); - /*! + /*! * Destroys this CommentFrame instance. */ - virtual ~CommentsFrame(); + virtual ~CommentsFrame(); - /*! + /*! * Returns the text of this comment. * * \see text() */ - virtual String toString() const; + virtual String toString() const; - /*! + /*! * Returns the language encoding as a 3 byte encoding as specified by * ISO-639-2. * @@ -77,48 +76,48 @@ namespace TagLib { * * \see setLanguage() */ - ByteVector language() const; + ByteVector language() const; - /*! + /*! * Returns the description of this comment. * * \note Most taggers simply ignore this value. * * \see setDescription() */ - String description() const; + String description() const; - /*! + /*! * Returns the text of this comment. * * \see setText() */ - String text() const; + String text() const; - /*! + /*! * Set the language using the 3 byte language code from * ISO-639-2 to * \a languageCode. * * \see language() */ - void setLanguage(const ByteVector &languageCode); + void setLanguage(const ByteVector &languageCode); - /*! + /*! * Sets the description of the comment to \a s. * * \see description() */ - void setDescription(const String &s); + void setDescription(const String &s); - /*! + /*! * Sets the text portion of the comment to \a s. * * \see text() */ - virtual void setText(const String &s); + virtual void setText(const String &s); - /*! + /*! * Returns the text encoding that will be used in rendering this frame. * This defaults to the type that was either specified in the constructor * or read from the frame when parsed. @@ -126,18 +125,18 @@ namespace TagLib { * \see setTextEncoding() * \see render() */ - String::Type textEncoding() const; + String::Type textEncoding() const; - /*! + /*! * Sets the text encoding to be used when rendering this frame to * \a encoding. * * \see textEncoding() * \see render() */ - void setTextEncoding(String::Type encoding); + void setTextEncoding(String::Type encoding); - /*! + /*! * Parses this frame as PropertyMap with a single key. * - if description() is empty or "COMMENT", the key will be "COMMENT" * - if description() is not a valid PropertyMap key, the frame will be @@ -146,36 +145,36 @@ namespace TagLib { * - otherwise, the key will be "COMMENT:" * - The single value will be the frame's text(). */ - PropertyMap asProperties() const; + PropertyMap asProperties() const; - /*! + /*! * Comments each have a unique description. This searches for a comment * frame with the description \a d and returns a pointer to it. If no * frame is found that matches the given description null is returned. * * \see description() */ - static CommentsFrame *findByDescription(const Tag *tag, const String &d); + static CommentsFrame *findByDescription(const Tag *tag, const String &d); - protected: - // Reimplementations. + protected: + // Reimplementations. - virtual void parseFields(const ByteVector &data); - virtual ByteVector renderFields() const; + virtual void parseFields(const ByteVector &data); + virtual ByteVector renderFields() const; - private: - /*! + private: + /*! * The constructor used by the FrameFactory. */ - CommentsFrame(const ByteVector &data, Header *h); - CommentsFrame(const CommentsFrame &); - CommentsFrame &operator=(const CommentsFrame &); + CommentsFrame(const ByteVector &data, Header *h); + CommentsFrame(const CommentsFrame &); + CommentsFrame &operator=(const CommentsFrame &); - class CommentsFramePrivate; - CommentsFramePrivate *d; - }; + class CommentsFramePrivate; + CommentsFramePrivate *d; +}; - } -} -} +} // namespace ID3v2 +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/id3v2/frames/eventtimingcodesframe.cpp b/3rdparty/taglib/mpeg/id3v2/frames/eventtimingcodesframe.cpp index 6e0b1bc1c..4078e54e3 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/eventtimingcodesframe.cpp +++ b/3rdparty/taglib/mpeg/id3v2/frames/eventtimingcodesframe.cpp @@ -32,11 +32,9 @@ using namespace Strawberry_TagLib::TagLib; using namespace ID3v2; -class EventTimingCodesFrame::EventTimingCodesFramePrivate -{ -public: - EventTimingCodesFramePrivate() : - timestampFormat(EventTimingCodesFrame::AbsoluteMilliseconds) {} +class EventTimingCodesFrame::EventTimingCodesFramePrivate { + public: + EventTimingCodesFramePrivate() : timestampFormat(EventTimingCodesFrame::AbsoluteMilliseconds) {} EventTimingCodesFrame::TimestampFormat timestampFormat; EventTimingCodesFrame::SynchedEventList synchedEvents; }; @@ -45,50 +43,40 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -EventTimingCodesFrame::EventTimingCodesFrame() : - Frame("ETCO"), - d(new EventTimingCodesFramePrivate()) -{ +EventTimingCodesFrame::EventTimingCodesFrame() : Frame("ETCO"), + d(new EventTimingCodesFramePrivate()) { } -EventTimingCodesFrame::EventTimingCodesFrame(const ByteVector &data) : - Frame(data), - d(new EventTimingCodesFramePrivate()) -{ +EventTimingCodesFrame::EventTimingCodesFrame(const ByteVector &data) : Frame(data), + d(new EventTimingCodesFramePrivate()) { setData(data); } -EventTimingCodesFrame::~EventTimingCodesFrame() -{ +EventTimingCodesFrame::~EventTimingCodesFrame() { delete d; } -String EventTimingCodesFrame::toString() const -{ +String EventTimingCodesFrame::toString() const { return String(); } EventTimingCodesFrame::TimestampFormat -EventTimingCodesFrame::timestampFormat() const -{ +EventTimingCodesFrame::timestampFormat() const { return d->timestampFormat; } EventTimingCodesFrame::SynchedEventList -EventTimingCodesFrame::synchedEvents() const -{ +EventTimingCodesFrame::synchedEvents() const { return d->synchedEvents; } void EventTimingCodesFrame::setTimestampFormat( - EventTimingCodesFrame::TimestampFormat f) -{ + EventTimingCodesFrame::TimestampFormat f) { d->timestampFormat = f; } void EventTimingCodesFrame::setSynchedEvents( - const EventTimingCodesFrame::SynchedEventList &e) -{ + const EventTimingCodesFrame::SynchedEventList &e) { d->synchedEvents = e; } @@ -96,10 +84,9 @@ void EventTimingCodesFrame::setSynchedEvents( // protected members //////////////////////////////////////////////////////////////////////////////// -void EventTimingCodesFrame::parseFields(const ByteVector &data) -{ +void EventTimingCodesFrame::parseFields(const ByteVector &data) { const int end = data.size(); - if(end < 1) { + if (end < 1) { debug("An event timing codes frame must contain at least 1 byte."); return; } @@ -108,7 +95,7 @@ void EventTimingCodesFrame::parseFields(const ByteVector &data) int pos = 1; d->synchedEvents.clear(); - while(pos + 4 < end) { + while (pos + 4 < end) { EventType type = static_cast(static_cast(data[pos++])); unsigned int time = data.toUInt(pos, true); pos += 4; @@ -116,14 +103,13 @@ void EventTimingCodesFrame::parseFields(const ByteVector &data) } } -ByteVector EventTimingCodesFrame::renderFields() const -{ +ByteVector EventTimingCodesFrame::renderFields() const { ByteVector v; v.append(char(d->timestampFormat)); - for(SynchedEventList::ConstIterator it = d->synchedEvents.begin(); - it != d->synchedEvents.end(); - ++it) { + for (SynchedEventList::ConstIterator it = d->synchedEvents.begin(); + it != d->synchedEvents.end(); + ++it) { const SynchedEvent &entry = *it; v.append(char(entry.type)); v.append(ByteVector::fromUInt(entry.time)); @@ -136,9 +122,7 @@ ByteVector EventTimingCodesFrame::renderFields() const // private members //////////////////////////////////////////////////////////////////////////////// -EventTimingCodesFrame::EventTimingCodesFrame(const ByteVector &data, Header *h) : - Frame(h), - d(new EventTimingCodesFramePrivate()) -{ +EventTimingCodesFrame::EventTimingCodesFrame(const ByteVector &data, Header *h) : Frame(h), + d(new EventTimingCodesFramePrivate()) { parseFields(fieldData(data)); } diff --git a/3rdparty/taglib/mpeg/id3v2/frames/eventtimingcodesframe.h b/3rdparty/taglib/mpeg/id3v2/frames/eventtimingcodesframe.h index a5f9035fb..3334c8f64 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/eventtimingcodesframe.h +++ b/3rdparty/taglib/mpeg/id3v2/frames/eventtimingcodesframe.h @@ -32,156 +32,154 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace ID3v2 { +namespace ID3v2 { - //! ID3v2 event timing codes frame - /*! +//! ID3v2 event timing codes frame +/*! * An implementation of ID3v2 event timing codes. */ - class TAGLIB_EXPORT EventTimingCodesFrame : public Frame - { - friend class FrameFactory; +class TAGLIB_EXPORT EventTimingCodesFrame : public Frame { + friend class FrameFactory; - public: - - /*! + public: + /*! * Specifies the timestamp format used. */ - enum TimestampFormat { - //! The timestamp is of unknown format. - Unknown = 0x00, - //! The timestamp represents the number of MPEG frames since - //! the beginning of the audio stream. - AbsoluteMpegFrames = 0x01, - //! The timestamp represents the number of milliseconds since - //! the beginning of the audio stream. - AbsoluteMilliseconds = 0x02 - }; + enum TimestampFormat { + //! The timestamp is of unknown format. + Unknown = 0x00, + //! The timestamp represents the number of MPEG frames since + //! the beginning of the audio stream. + AbsoluteMpegFrames = 0x01, + //! The timestamp represents the number of milliseconds since + //! the beginning of the audio stream. + AbsoluteMilliseconds = 0x02 + }; - /*! + /*! * Event types defined in id3v2.4.0-frames.txt 4.5. Event timing codes. */ - enum EventType { - Padding = 0x00, - EndOfInitialSilence = 0x01, - IntroStart = 0x02, - MainPartStart = 0x03, - OutroStart = 0x04, - OutroEnd = 0x05, - VerseStart = 0x06, - RefrainStart = 0x07, - InterludeStart = 0x08, - ThemeStart = 0x09, - VariationStart = 0x0a, - KeyChange = 0x0b, - TimeChange = 0x0c, - MomentaryUnwantedNoise = 0x0d, - SustainedNoise = 0x0e, - SustainedNoiseEnd = 0x0f, - IntroEnd = 0x10, - MainPartEnd = 0x11, - VerseEnd = 0x12, - RefrainEnd = 0x13, - ThemeEnd = 0x14, - Profanity = 0x15, - ProfanityEnd = 0x16, - NotPredefinedSynch0 = 0xe0, - NotPredefinedSynch1 = 0xe1, - NotPredefinedSynch2 = 0xe2, - NotPredefinedSynch3 = 0xe3, - NotPredefinedSynch4 = 0xe4, - NotPredefinedSynch5 = 0xe5, - NotPredefinedSynch6 = 0xe6, - NotPredefinedSynch7 = 0xe7, - NotPredefinedSynch8 = 0xe8, - NotPredefinedSynch9 = 0xe9, - NotPredefinedSynchA = 0xea, - NotPredefinedSynchB = 0xeb, - NotPredefinedSynchC = 0xec, - NotPredefinedSynchD = 0xed, - NotPredefinedSynchE = 0xee, - NotPredefinedSynchF = 0xef, - AudioEnd = 0xfd, - AudioFileEnds = 0xfe - }; + enum EventType { + Padding = 0x00, + EndOfInitialSilence = 0x01, + IntroStart = 0x02, + MainPartStart = 0x03, + OutroStart = 0x04, + OutroEnd = 0x05, + VerseStart = 0x06, + RefrainStart = 0x07, + InterludeStart = 0x08, + ThemeStart = 0x09, + VariationStart = 0x0a, + KeyChange = 0x0b, + TimeChange = 0x0c, + MomentaryUnwantedNoise = 0x0d, + SustainedNoise = 0x0e, + SustainedNoiseEnd = 0x0f, + IntroEnd = 0x10, + MainPartEnd = 0x11, + VerseEnd = 0x12, + RefrainEnd = 0x13, + ThemeEnd = 0x14, + Profanity = 0x15, + ProfanityEnd = 0x16, + NotPredefinedSynch0 = 0xe0, + NotPredefinedSynch1 = 0xe1, + NotPredefinedSynch2 = 0xe2, + NotPredefinedSynch3 = 0xe3, + NotPredefinedSynch4 = 0xe4, + NotPredefinedSynch5 = 0xe5, + NotPredefinedSynch6 = 0xe6, + NotPredefinedSynch7 = 0xe7, + NotPredefinedSynch8 = 0xe8, + NotPredefinedSynch9 = 0xe9, + NotPredefinedSynchA = 0xea, + NotPredefinedSynchB = 0xeb, + NotPredefinedSynchC = 0xec, + NotPredefinedSynchD = 0xed, + NotPredefinedSynchE = 0xee, + NotPredefinedSynchF = 0xef, + AudioEnd = 0xfd, + AudioFileEnds = 0xfe + }; - /*! + /*! * Single entry of time stamp and event. */ - struct SynchedEvent { - SynchedEvent(unsigned int ms, EventType t) : time(ms), type(t) {} - unsigned int time; - EventType type; - }; + struct SynchedEvent { + SynchedEvent(unsigned int ms, EventType t) : time(ms), type(t) {} + unsigned int time; + EventType type; + }; - /*! + /*! * List of synchronized events. */ - typedef Strawberry_TagLib::TagLib::List SynchedEventList; + typedef Strawberry_TagLib::TagLib::List SynchedEventList; - /*! + /*! * Construct an empty event timing codes frame. */ - explicit EventTimingCodesFrame(); + explicit EventTimingCodesFrame(); - /*! + /*! * Construct a event timing codes frame based on the data in \a data. */ - explicit EventTimingCodesFrame(const ByteVector &data); + explicit EventTimingCodesFrame(const ByteVector &data); - /*! + /*! * Destroys this EventTimingCodesFrame instance. */ - virtual ~EventTimingCodesFrame(); + virtual ~EventTimingCodesFrame(); - /*! + /*! * Returns a null string. */ - virtual String toString() const; + virtual String toString() const; - /*! + /*! * Returns the timestamp format. */ - TimestampFormat timestampFormat() const; + TimestampFormat timestampFormat() const; - /*! + /*! * Returns the events with the time stamps. */ - SynchedEventList synchedEvents() const; + SynchedEventList synchedEvents() const; - /*! + /*! * Set the timestamp format. * * \see timestampFormat() */ - void setTimestampFormat(TimestampFormat f); + void setTimestampFormat(TimestampFormat f); - /*! + /*! * Sets the text with the time stamps. * * \see text() */ - void setSynchedEvents(const SynchedEventList &e); + void setSynchedEvents(const SynchedEventList &e); - protected: - // Reimplementations. + protected: + // Reimplementations. - virtual void parseFields(const ByteVector &data); - virtual ByteVector renderFields() const; + virtual void parseFields(const ByteVector &data); + virtual ByteVector renderFields() const; - private: - /*! + private: + /*! * The constructor used by the FrameFactory. */ - EventTimingCodesFrame(const ByteVector &data, Header *h); - EventTimingCodesFrame(const EventTimingCodesFrame &); - EventTimingCodesFrame &operator=(const EventTimingCodesFrame &); + EventTimingCodesFrame(const ByteVector &data, Header *h); + EventTimingCodesFrame(const EventTimingCodesFrame &); + EventTimingCodesFrame &operator=(const EventTimingCodesFrame &); - class EventTimingCodesFramePrivate; - EventTimingCodesFramePrivate *d; - }; + class EventTimingCodesFramePrivate; + EventTimingCodesFramePrivate *d; +}; - } -} -} +} // namespace ID3v2 +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/id3v2/frames/generalencapsulatedobjectframe.cpp b/3rdparty/taglib/mpeg/id3v2/frames/generalencapsulatedobjectframe.cpp index cafda8971..dffe30a06 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/generalencapsulatedobjectframe.cpp +++ b/3rdparty/taglib/mpeg/id3v2/frames/generalencapsulatedobjectframe.cpp @@ -34,9 +34,8 @@ using namespace Strawberry_TagLib::TagLib; using namespace ID3v2; -class GeneralEncapsulatedObjectFrame::GeneralEncapsulatedObjectFramePrivate -{ -public: +class GeneralEncapsulatedObjectFrame::GeneralEncapsulatedObjectFramePrivate { + public: GeneralEncapsulatedObjectFramePrivate() : textEncoding(String::Latin1) {} String::Type textEncoding; @@ -50,84 +49,68 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -GeneralEncapsulatedObjectFrame::GeneralEncapsulatedObjectFrame() : - Frame("GEOB"), - d(new GeneralEncapsulatedObjectFramePrivate()) -{ +GeneralEncapsulatedObjectFrame::GeneralEncapsulatedObjectFrame() : Frame("GEOB"), + d(new GeneralEncapsulatedObjectFramePrivate()) { } -GeneralEncapsulatedObjectFrame::GeneralEncapsulatedObjectFrame(const ByteVector &data) : - Frame(data), - d(new GeneralEncapsulatedObjectFramePrivate()) -{ +GeneralEncapsulatedObjectFrame::GeneralEncapsulatedObjectFrame(const ByteVector &data) : Frame(data), + d(new GeneralEncapsulatedObjectFramePrivate()) { setData(data); } -GeneralEncapsulatedObjectFrame::~GeneralEncapsulatedObjectFrame() -{ +GeneralEncapsulatedObjectFrame::~GeneralEncapsulatedObjectFrame() { delete d; } -String GeneralEncapsulatedObjectFrame::toString() const -{ +String GeneralEncapsulatedObjectFrame::toString() const { String text = "[" + d->mimeType + "]"; - if(!d->fileName.isEmpty()) + if (!d->fileName.isEmpty()) text += " " + d->fileName; - if(!d->description.isEmpty()) + if (!d->description.isEmpty()) text += " \"" + d->description + "\""; return text; } -String::Type GeneralEncapsulatedObjectFrame::textEncoding() const -{ +String::Type GeneralEncapsulatedObjectFrame::textEncoding() const { return d->textEncoding; } -void GeneralEncapsulatedObjectFrame::setTextEncoding(String::Type encoding) -{ +void GeneralEncapsulatedObjectFrame::setTextEncoding(String::Type encoding) { d->textEncoding = encoding; } -String GeneralEncapsulatedObjectFrame::mimeType() const -{ +String GeneralEncapsulatedObjectFrame::mimeType() const { return d->mimeType; } -void GeneralEncapsulatedObjectFrame::setMimeType(const String &type) -{ +void GeneralEncapsulatedObjectFrame::setMimeType(const String &type) { d->mimeType = type; } -String GeneralEncapsulatedObjectFrame::fileName() const -{ +String GeneralEncapsulatedObjectFrame::fileName() const { return d->fileName; } -void GeneralEncapsulatedObjectFrame::setFileName(const String &name) -{ +void GeneralEncapsulatedObjectFrame::setFileName(const String &name) { d->fileName = name; } -String GeneralEncapsulatedObjectFrame::description() const -{ +String GeneralEncapsulatedObjectFrame::description() const { return d->description; } -void GeneralEncapsulatedObjectFrame::setDescription(const String &desc) -{ +void GeneralEncapsulatedObjectFrame::setDescription(const String &desc) { d->description = desc; } -ByteVector GeneralEncapsulatedObjectFrame::object() const -{ +ByteVector GeneralEncapsulatedObjectFrame::object() const { return d->data; } -void GeneralEncapsulatedObjectFrame::setObject(const ByteVector &data) -{ +void GeneralEncapsulatedObjectFrame::setObject(const ByteVector &data) { d->data = data; } @@ -135,9 +118,8 @@ void GeneralEncapsulatedObjectFrame::setObject(const ByteVector &data) // protected members //////////////////////////////////////////////////////////////////////////////// -void GeneralEncapsulatedObjectFrame::parseFields(const ByteVector &data) -{ - if(data.size() < 4) { +void GeneralEncapsulatedObjectFrame::parseFields(const ByteVector &data) { + if (data.size() < 4) { debug("An object frame must contain at least 4 bytes."); return; } @@ -153,8 +135,7 @@ void GeneralEncapsulatedObjectFrame::parseFields(const ByteVector &data) d->data = data.mid(pos); } -ByteVector GeneralEncapsulatedObjectFrame::renderFields() const -{ +ByteVector GeneralEncapsulatedObjectFrame::renderFields() const { StringList sl; sl.append(d->fileName); sl.append(d->description); @@ -179,9 +160,7 @@ ByteVector GeneralEncapsulatedObjectFrame::renderFields() const // private members //////////////////////////////////////////////////////////////////////////////// -GeneralEncapsulatedObjectFrame::GeneralEncapsulatedObjectFrame(const ByteVector &data, Header *h) : - Frame(h), - d(new GeneralEncapsulatedObjectFramePrivate()) -{ +GeneralEncapsulatedObjectFrame::GeneralEncapsulatedObjectFrame(const ByteVector &data, Header *h) : Frame(h), + d(new GeneralEncapsulatedObjectFramePrivate()) { parseFields(fieldData(data)); } diff --git a/3rdparty/taglib/mpeg/id3v2/frames/generalencapsulatedobjectframe.h b/3rdparty/taglib/mpeg/id3v2/frames/generalencapsulatedobjectframe.h index 66de31b74..d814ce7da 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/generalencapsulatedobjectframe.h +++ b/3rdparty/taglib/mpeg/id3v2/frames/generalencapsulatedobjectframe.h @@ -36,11 +36,11 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace ID3v2 { +namespace ID3v2 { - //! An ID3v2 general encapsulated object frame implementation +//! An ID3v2 general encapsulated object frame implementation - /*! +/*! * This is an implementation of ID3v2 general encapsulated objects. * Arbitrary binary data may be included in tags, stored in GEOB frames. * There may be multiple GEOB frames in a single tag. Each GEOB it @@ -49,79 +49,77 @@ namespace TagLib { * uniquely identifies the GEOB frame in the tag. */ - class TAGLIB_EXPORT GeneralEncapsulatedObjectFrame : public Frame - { - friend class FrameFactory; +class TAGLIB_EXPORT GeneralEncapsulatedObjectFrame : public Frame { + friend class FrameFactory; - public: - - /*! + public: + /*! * Constructs an empty object frame. The description, file name and text * encoding should be set manually. */ - GeneralEncapsulatedObjectFrame(); + GeneralEncapsulatedObjectFrame(); - /*! + /*! * Constructs a GeneralEncapsulatedObjectFrame frame based on \a data. * * \warning This is \em not data for the encapsulated object, for that use * setObject(). This constructor is used when reading the frame from the * disk. */ - explicit GeneralEncapsulatedObjectFrame(const ByteVector &data); + explicit GeneralEncapsulatedObjectFrame(const ByteVector &data); - /*! + /*! * Destroys the GeneralEncapsulatedObjectFrame instance. */ - virtual ~GeneralEncapsulatedObjectFrame(); + virtual ~GeneralEncapsulatedObjectFrame(); - /*! + /*! * Returns a string containing the description, file name and mime-type */ - virtual String toString() const; + virtual String toString() const; - /*! + /*! * Returns the text encoding used for the description and file name. * * \see setTextEncoding() * \see description() * \see fileName() */ - String::Type textEncoding() const; + String::Type textEncoding() const; - /*! + /*! * Set the text encoding used for the description and file name. * * \see description() * \see fileName() */ - void setTextEncoding(String::Type encoding); + void setTextEncoding(String::Type encoding); - /*! + /*! * Returns the mime type of the object. */ - String mimeType() const; + String mimeType() const; - /*! + /*! * Sets the mime type of the object. */ - void setMimeType(const String &type); + void setMimeType(const String &type); - /*! + /*! * Returns the file name of the object. * * \see setFileName() */ - String fileName() const; + String fileName() const; - /*! + /*! * Sets the file name for the object. * * \see fileName() */ - void setFileName(const String &name); + void setFileName(const String &name); - /*! + /*! * Returns the content description of the object. * * \see setDescription() @@ -129,9 +127,9 @@ namespace TagLib { * \see setTextEncoding() */ - String description() const; + String description() const; - /*! + /*! * Sets the content description of the object to \a desc. * * \see description() @@ -139,9 +137,9 @@ namespace TagLib { * \see setTextEncoding() */ - void setDescription(const String &desc); + void setDescription(const String &desc); - /*! + /*! * Returns the object data as a ByteVector. * * \note ByteVector has a data() method that returns a const char * which @@ -150,9 +148,9 @@ namespace TagLib { * \see setObject() * \see mimeType() */ - ByteVector object() const; + ByteVector object() const; - /*! + /*! * Sets the object data to \a data. \a data should be of the type specified in * this frame's mime-type specification. * @@ -160,22 +158,22 @@ namespace TagLib { * \see mimeType() * \see setMimeType() */ - void setObject(const ByteVector &object); + void setObject(const ByteVector &object); - protected: - virtual void parseFields(const ByteVector &data); - virtual ByteVector renderFields() const; + protected: + virtual void parseFields(const ByteVector &data); + virtual ByteVector renderFields() const; - private: - GeneralEncapsulatedObjectFrame(const ByteVector &data, Header *h); - GeneralEncapsulatedObjectFrame(const GeneralEncapsulatedObjectFrame &); - GeneralEncapsulatedObjectFrame &operator=(const GeneralEncapsulatedObjectFrame &); + private: + GeneralEncapsulatedObjectFrame(const ByteVector &data, Header *h); + GeneralEncapsulatedObjectFrame(const GeneralEncapsulatedObjectFrame &); + GeneralEncapsulatedObjectFrame &operator=(const GeneralEncapsulatedObjectFrame &); - class GeneralEncapsulatedObjectFramePrivate; - GeneralEncapsulatedObjectFramePrivate *d; - }; - } -} -} + class GeneralEncapsulatedObjectFramePrivate; + GeneralEncapsulatedObjectFramePrivate *d; +}; +} // namespace ID3v2 +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/id3v2/frames/ownershipframe.cpp b/3rdparty/taglib/mpeg/id3v2/frames/ownershipframe.cpp index 91795fc7f..dc4319602 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/ownershipframe.cpp +++ b/3rdparty/taglib/mpeg/id3v2/frames/ownershipframe.cpp @@ -32,9 +32,8 @@ using namespace Strawberry_TagLib::TagLib; using namespace ID3v2; -class OwnershipFrame::OwnershipFramePrivate -{ -public: +class OwnershipFrame::OwnershipFramePrivate { + public: String pricePaid; String datePurchased; String seller; @@ -45,67 +44,53 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -OwnershipFrame::OwnershipFrame(String::Type encoding) : - Frame("OWNE"), - d(new OwnershipFramePrivate()) -{ +OwnershipFrame::OwnershipFrame(String::Type encoding) : Frame("OWNE"), + d(new OwnershipFramePrivate()) { d->textEncoding = encoding; } -OwnershipFrame::OwnershipFrame(const ByteVector &data) : - Frame(data), - d(new OwnershipFramePrivate()) -{ +OwnershipFrame::OwnershipFrame(const ByteVector &data) : Frame(data), + d(new OwnershipFramePrivate()) { setData(data); } -OwnershipFrame::~OwnershipFrame() -{ +OwnershipFrame::~OwnershipFrame() { delete d; } -String OwnershipFrame::toString() const -{ +String OwnershipFrame::toString() const { return "pricePaid=" + d->pricePaid + " datePurchased=" + d->datePurchased + " seller=" + d->seller; } -String OwnershipFrame::pricePaid() const -{ +String OwnershipFrame::pricePaid() const { return d->pricePaid; } -void OwnershipFrame::setPricePaid(const String &s) -{ +void OwnershipFrame::setPricePaid(const String &s) { d->pricePaid = s; } -String OwnershipFrame::datePurchased() const -{ +String OwnershipFrame::datePurchased() const { return d->datePurchased; } -void OwnershipFrame::setDatePurchased(const String &s) -{ +void OwnershipFrame::setDatePurchased(const String &s) { d->datePurchased = s; } -String OwnershipFrame::seller() const -{ +String OwnershipFrame::seller() const { return d->seller; } -void OwnershipFrame::setSeller(const String &s) -{ +void OwnershipFrame::setSeller(const String &s) { d->seller = s; } -String::Type OwnershipFrame::textEncoding() const -{ +String::Type OwnershipFrame::textEncoding() const { return d->textEncoding; } -void OwnershipFrame::setTextEncoding(String::Type encoding) -{ +void OwnershipFrame::setTextEncoding(String::Type encoding) { d->textEncoding = encoding; } @@ -113,8 +98,7 @@ void OwnershipFrame::setTextEncoding(String::Type encoding) // protected members //////////////////////////////////////////////////////////////////////////////// -void OwnershipFrame::parseFields(const ByteVector &data) -{ +void OwnershipFrame::parseFields(const ByteVector &data) { int pos = 0; // Get the text encoding @@ -126,7 +110,7 @@ void OwnershipFrame::parseFields(const ByteVector &data) // If we don't have at least 8 bytes left then don't parse the rest of the // data - if(data.size() - pos < 8) { + if (data.size() - pos < 8) { return; } @@ -135,14 +119,13 @@ void OwnershipFrame::parseFields(const ByteVector &data) pos += 8; // Read the seller - if(d->textEncoding == String::Latin1) + if (d->textEncoding == String::Latin1) d->seller = Tag::latin1StringHandler()->parse(data.mid(pos)); else d->seller = String(data.mid(pos), d->textEncoding); } -ByteVector OwnershipFrame::renderFields() const -{ +ByteVector OwnershipFrame::renderFields() const { StringList sl; sl.append(d->seller); @@ -163,9 +146,7 @@ ByteVector OwnershipFrame::renderFields() const // private members //////////////////////////////////////////////////////////////////////////////// -OwnershipFrame::OwnershipFrame(const ByteVector &data, Header *h) : - Frame(h), - d(new OwnershipFramePrivate()) -{ +OwnershipFrame::OwnershipFrame(const ByteVector &data, Header *h) : Frame(h), + d(new OwnershipFramePrivate()) { parseFields(fieldData(data)); } diff --git a/3rdparty/taglib/mpeg/id3v2/frames/ownershipframe.h b/3rdparty/taglib/mpeg/id3v2/frames/ownershipframe.h index e55bdbac7..8efbf69c2 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/ownershipframe.h +++ b/3rdparty/taglib/mpeg/id3v2/frames/ownershipframe.h @@ -32,85 +32,84 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace ID3v2 { +namespace ID3v2 { - //! An implementation of ID3v2 "ownership" +//! An implementation of ID3v2 "ownership" - /*! +/*! * This implements the ID3v2 ownership (OWNE frame). It consists of * a price paid, a date purchased (YYYYMMDD) and the name of the seller. */ - class TAGLIB_EXPORT OwnershipFrame : public Frame - { - friend class FrameFactory; +class TAGLIB_EXPORT OwnershipFrame : public Frame { + friend class FrameFactory; - public: - /*! + public: + /*! * Construct an empty ownership frame. */ - explicit OwnershipFrame(String::Type encoding = String::Latin1); + explicit OwnershipFrame(String::Type encoding = String::Latin1); - /*! + /*! * Construct a ownership based on the data in \a data. */ - explicit OwnershipFrame(const ByteVector &data); + explicit OwnershipFrame(const ByteVector &data); - /*! + /*! * Destroys this OwnershipFrame instance. */ - virtual ~OwnershipFrame(); + virtual ~OwnershipFrame(); - /*! + /*! * Returns the text of this popularimeter. * * \see text() */ - virtual String toString() const; + virtual String toString() const; - /*! + /*! * Returns the date purchased. * * \see setDatePurchased() */ - String datePurchased() const; + String datePurchased() const; - /*! + /*! * Set the date purchased. * * \see datePurchased() */ - void setDatePurchased(const String &datePurchased); + void setDatePurchased(const String &datePurchased); - /*! + /*! * Returns the price paid. * * \see setPricePaid() */ - String pricePaid() const; + String pricePaid() const; - /*! + /*! * Set the price paid. * * \see pricePaid() */ - void setPricePaid(const String &pricePaid); + void setPricePaid(const String &pricePaid); - /*! + /*! * Returns the seller. * * \see setSeller() */ - String seller() const; + String seller() const; - /*! + /*! * Set the seller. * * \see seller() */ - void setSeller(const String &seller); + void setSeller(const String &seller); - /*! + /*! * Returns the text encoding that will be used in rendering this frame. * This defaults to the type that was either specified in the constructor * or read from the frame when parsed. @@ -118,36 +117,36 @@ namespace TagLib { * \see setTextEncoding() * \see render() */ - String::Type textEncoding() const; + String::Type textEncoding() const; - /*! + /*! * Sets the text encoding to be used when rendering this frame to * \a encoding. * * \see textEncoding() * \see render() */ - void setTextEncoding(String::Type encoding); + void setTextEncoding(String::Type encoding); - protected: - // Reimplementations. + protected: + // Reimplementations. - virtual void parseFields(const ByteVector &data); - virtual ByteVector renderFields() const; + virtual void parseFields(const ByteVector &data); + virtual ByteVector renderFields() const; - private: - /*! + private: + /*! * The constructor used by the FrameFactory. */ - OwnershipFrame(const ByteVector &data, Header *h); - OwnershipFrame(const OwnershipFrame &); - OwnershipFrame &operator=(const OwnershipFrame &); + OwnershipFrame(const ByteVector &data, Header *h); + OwnershipFrame(const OwnershipFrame &); + OwnershipFrame &operator=(const OwnershipFrame &); - class OwnershipFramePrivate; - OwnershipFramePrivate *d; - }; + class OwnershipFramePrivate; + OwnershipFramePrivate *d; +}; - } -} -} +} // namespace ID3v2 +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/id3v2/frames/podcastframe.cpp b/3rdparty/taglib/mpeg/id3v2/frames/podcastframe.cpp index 359b5e743..aeb2e8388 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/podcastframe.cpp +++ b/3rdparty/taglib/mpeg/id3v2/frames/podcastframe.cpp @@ -28,9 +28,8 @@ using namespace Strawberry_TagLib::TagLib; using namespace ID3v2; -class PodcastFrame::PodcastFramePrivate -{ -public: +class PodcastFrame::PodcastFramePrivate { + public: ByteVector fieldData; }; @@ -38,20 +37,16 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -PodcastFrame::PodcastFrame() : - Frame("PCST"), - d(new PodcastFramePrivate()) -{ +PodcastFrame::PodcastFrame() : Frame("PCST"), + d(new PodcastFramePrivate()) { d->fieldData = ByteVector(4, '\0'); } -PodcastFrame::~PodcastFrame() -{ +PodcastFrame::~PodcastFrame() { delete d; } -String PodcastFrame::toString() const -{ +String PodcastFrame::toString() const { return String(); } @@ -59,13 +54,11 @@ String PodcastFrame::toString() const // protected members //////////////////////////////////////////////////////////////////////////////// -void PodcastFrame::parseFields(const ByteVector &data) -{ +void PodcastFrame::parseFields(const ByteVector &data) { d->fieldData = data; } -ByteVector PodcastFrame::renderFields() const -{ +ByteVector PodcastFrame::renderFields() const { return d->fieldData; } @@ -73,9 +66,7 @@ ByteVector PodcastFrame::renderFields() const // private members //////////////////////////////////////////////////////////////////////////////// -PodcastFrame::PodcastFrame(const ByteVector &data, Header *h) : - Frame(h), - d(new PodcastFramePrivate()) -{ +PodcastFrame::PodcastFrame(const ByteVector &data, Header *h) : Frame(h), + d(new PodcastFramePrivate()) { parseFields(fieldData(data)); } diff --git a/3rdparty/taglib/mpeg/id3v2/frames/podcastframe.h b/3rdparty/taglib/mpeg/id3v2/frames/podcastframe.h index 9bb865631..9c3c34e26 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/podcastframe.h +++ b/3rdparty/taglib/mpeg/id3v2/frames/podcastframe.h @@ -32,51 +32,50 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace ID3v2 { +namespace ID3v2 { - //! ID3v2 podcast frame - /*! +//! ID3v2 podcast frame +/*! * An implementation of ID3v2 podcast flag, a frame with four zero bytes. */ - class TAGLIB_EXPORT PodcastFrame : public Frame - { - friend class FrameFactory; +class TAGLIB_EXPORT PodcastFrame : public Frame { + friend class FrameFactory; - public: - /*! + public: + /*! * Construct a podcast frame. */ - PodcastFrame(); + PodcastFrame(); - /*! + /*! * Destroys this PodcastFrame instance. */ - virtual ~PodcastFrame(); + virtual ~PodcastFrame(); - /*! + /*! * Returns a null string. */ - virtual String toString() const; + virtual String toString() const; - protected: - // Reimplementations. + protected: + // Reimplementations. - virtual void parseFields(const ByteVector &data); - virtual ByteVector renderFields() const; + virtual void parseFields(const ByteVector &data); + virtual ByteVector renderFields() const; - private: - /*! + private: + /*! * The constructor used by the FrameFactory. */ - PodcastFrame(const ByteVector &data, Header *h); - PodcastFrame(const PodcastFrame &); - PodcastFrame &operator=(const PodcastFrame &); + PodcastFrame(const ByteVector &data, Header *h); + PodcastFrame(const PodcastFrame &); + PodcastFrame &operator=(const PodcastFrame &); - class PodcastFramePrivate; - PodcastFramePrivate *d; - }; + class PodcastFramePrivate; + PodcastFramePrivate *d; +}; - } -} -} +} // namespace ID3v2 +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/id3v2/frames/popularimeterframe.cpp b/3rdparty/taglib/mpeg/id3v2/frames/popularimeterframe.cpp index 3a5c22b5b..5be0f8003 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/popularimeterframe.cpp +++ b/3rdparty/taglib/mpeg/id3v2/frames/popularimeterframe.cpp @@ -30,9 +30,8 @@ using namespace Strawberry_TagLib::TagLib; using namespace ID3v2; -class PopularimeterFrame::PopularimeterFramePrivate -{ -public: +class PopularimeterFrame::PopularimeterFramePrivate { + public: PopularimeterFramePrivate() : rating(0), counter(0) {} String email; int rating; @@ -43,56 +42,44 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -PopularimeterFrame::PopularimeterFrame() : - Frame("POPM"), - d(new PopularimeterFramePrivate()) -{ +PopularimeterFrame::PopularimeterFrame() : Frame("POPM"), + d(new PopularimeterFramePrivate()) { } -PopularimeterFrame::PopularimeterFrame(const ByteVector &data) : - Frame(data), - d(new PopularimeterFramePrivate()) -{ +PopularimeterFrame::PopularimeterFrame(const ByteVector &data) : Frame(data), + d(new PopularimeterFramePrivate()) { setData(data); } -PopularimeterFrame::~PopularimeterFrame() -{ +PopularimeterFrame::~PopularimeterFrame() { delete d; } -String PopularimeterFrame::toString() const -{ +String PopularimeterFrame::toString() const { return d->email + " rating=" + String::number(d->rating) + " counter=" + String::number(d->counter); } -String PopularimeterFrame::email() const -{ +String PopularimeterFrame::email() const { return d->email; } -void PopularimeterFrame::setEmail(const String &s) -{ +void PopularimeterFrame::setEmail(const String &s) { d->email = s; } -int PopularimeterFrame::rating() const -{ +int PopularimeterFrame::rating() const { return d->rating; } -void PopularimeterFrame::setRating(int s) -{ +void PopularimeterFrame::setRating(int s) { d->rating = s; } -unsigned int PopularimeterFrame::counter() const -{ +unsigned int PopularimeterFrame::counter() const { return d->counter; } -void PopularimeterFrame::setCounter(unsigned int s) -{ +void PopularimeterFrame::setCounter(unsigned int s) { d->counter = s; } @@ -100,24 +87,22 @@ void PopularimeterFrame::setCounter(unsigned int s) // protected members //////////////////////////////////////////////////////////////////////////////// -void PopularimeterFrame::parseFields(const ByteVector &data) -{ +void PopularimeterFrame::parseFields(const ByteVector &data) { int pos = 0, size = int(data.size()); d->email = readStringField(data, String::Latin1, &pos); d->rating = 0; d->counter = 0; - if(pos < size) { + if (pos < size) { d->rating = (unsigned char)(data[pos++]); - if(pos < size) { + if (pos < size) { d->counter = data.toUInt(static_cast(pos)); } } } -ByteVector PopularimeterFrame::renderFields() const -{ +ByteVector PopularimeterFrame::renderFields() const { ByteVector data; data.append(d->email.data(String::Latin1)); @@ -132,9 +117,7 @@ ByteVector PopularimeterFrame::renderFields() const // private members //////////////////////////////////////////////////////////////////////////////// -PopularimeterFrame::PopularimeterFrame(const ByteVector &data, Header *h) : - Frame(h), - d(new PopularimeterFramePrivate()) -{ +PopularimeterFrame::PopularimeterFrame(const ByteVector &data, Header *h) : Frame(h), + d(new PopularimeterFramePrivate()) { parseFields(fieldData(data)); } diff --git a/3rdparty/taglib/mpeg/id3v2/frames/popularimeterframe.h b/3rdparty/taglib/mpeg/id3v2/frames/popularimeterframe.h index 1dd9fa7ef..96216c29b 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/popularimeterframe.h +++ b/3rdparty/taglib/mpeg/id3v2/frames/popularimeterframe.h @@ -32,103 +32,102 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace ID3v2 { +namespace ID3v2 { - //! An implementation of ID3v2 "popularimeter" +//! An implementation of ID3v2 "popularimeter" - /*! +/*! * This implements the ID3v2 popularimeter (POPM frame). It consists of * an email, a rating and an optional counter. */ - class TAGLIB_EXPORT PopularimeterFrame : public Frame - { - friend class FrameFactory; +class TAGLIB_EXPORT PopularimeterFrame : public Frame { + friend class FrameFactory; - public: - /*! + public: + /*! * Construct an empty popularimeter frame. */ - explicit PopularimeterFrame(); + explicit PopularimeterFrame(); - /*! + /*! * Construct a popularimeter based on the data in \a data. */ - explicit PopularimeterFrame(const ByteVector &data); + explicit PopularimeterFrame(const ByteVector &data); - /*! + /*! * Destroys this PopularimeterFrame instance. */ - virtual ~PopularimeterFrame(); + virtual ~PopularimeterFrame(); - /*! + /*! * Returns the text of this popularimeter. * * \see text() */ - virtual String toString() const; + virtual String toString() const; - /*! + /*! * Returns the email. * * \see setEmail() */ - String email() const; + String email() const; - /*! + /*! * Set the email. * * \see email() */ - void setEmail(const String &email); + void setEmail(const String &email); - /*! + /*! * Returns the rating. * * \see setRating() */ - int rating() const; + int rating() const; - /*! + /*! * Set the rating. * * \see rating() */ - void setRating(int rating); + void setRating(int rating); - /*! + /*! * Returns the counter. * * \see setCounter() */ - unsigned int counter() const; + unsigned int counter() const; - /*! + /*! * Set the counter. * * \see counter() */ - void setCounter(unsigned int counter); + void setCounter(unsigned int counter); - protected: - // Reimplementations. + protected: + // Reimplementations. - virtual void parseFields(const ByteVector &data); - virtual ByteVector renderFields() const; + virtual void parseFields(const ByteVector &data); + virtual ByteVector renderFields() const; - private: - /*! + private: + /*! * The constructor used by the FrameFactory. */ - PopularimeterFrame(const ByteVector &data, Header *h); - PopularimeterFrame(const PopularimeterFrame &); - PopularimeterFrame &operator=(const PopularimeterFrame &); + PopularimeterFrame(const ByteVector &data, Header *h); + PopularimeterFrame(const PopularimeterFrame &); + PopularimeterFrame &operator=(const PopularimeterFrame &); - class PopularimeterFramePrivate; - PopularimeterFramePrivate *d; - }; + class PopularimeterFramePrivate; + PopularimeterFramePrivate *d; +}; - } -} -} +} // namespace ID3v2 +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/id3v2/frames/privateframe.cpp b/3rdparty/taglib/mpeg/id3v2/frames/privateframe.cpp index a1c0008d3..53bba7061 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/privateframe.cpp +++ b/3rdparty/taglib/mpeg/id3v2/frames/privateframe.cpp @@ -34,9 +34,8 @@ using namespace Strawberry_TagLib::TagLib; using namespace ID3v2; -class PrivateFrame::PrivateFramePrivate -{ -public: +class PrivateFrame::PrivateFramePrivate { + public: ByteVector data; String owner; }; @@ -45,46 +44,36 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -PrivateFrame::PrivateFrame() : - Frame("PRIV"), - d(new PrivateFramePrivate()) -{ +PrivateFrame::PrivateFrame() : Frame("PRIV"), + d(new PrivateFramePrivate()) { } -PrivateFrame::PrivateFrame(const ByteVector &data) : - Frame(data), - d(new PrivateFramePrivate()) -{ +PrivateFrame::PrivateFrame(const ByteVector &data) : Frame(data), + d(new PrivateFramePrivate()) { setData(data); } -PrivateFrame::~PrivateFrame() -{ +PrivateFrame::~PrivateFrame() { delete d; } -String PrivateFrame::toString() const -{ +String PrivateFrame::toString() const { return d->owner; } -String PrivateFrame::owner() const -{ +String PrivateFrame::owner() const { return d->owner; } -ByteVector PrivateFrame::data() const -{ +ByteVector PrivateFrame::data() const { return d->data; } -void PrivateFrame::setOwner(const String &s) -{ +void PrivateFrame::setOwner(const String &s) { d->owner = s; } -void PrivateFrame::setData(const ByteVector & data) -{ +void PrivateFrame::setData(const ByteVector &data) { d->data = data; } @@ -92,24 +81,22 @@ void PrivateFrame::setData(const ByteVector & data) // protected members //////////////////////////////////////////////////////////////////////////////// -void PrivateFrame::parseFields(const ByteVector &data) -{ - if(data.size() < 2) { +void PrivateFrame::parseFields(const ByteVector &data) { + if (data.size() < 2) { debug("A private frame must contain at least 2 bytes."); return; } // Owner identifier is assumed to be Latin1 - const int byteAlign = 1; + const int byteAlign = 1; const int endOfOwner = data.find(textDelimiter(String::Latin1), 0, byteAlign); - d->owner = String(data.mid(0, endOfOwner)); + d->owner = String(data.mid(0, endOfOwner)); d->data = data.mid(endOfOwner + 1); } -ByteVector PrivateFrame::renderFields() const -{ +ByteVector PrivateFrame::renderFields() const { ByteVector v; v.append(d->owner.data(String::Latin1)); @@ -123,9 +110,7 @@ ByteVector PrivateFrame::renderFields() const // private members //////////////////////////////////////////////////////////////////////////////// -PrivateFrame::PrivateFrame(const ByteVector &data, Header *h) : - Frame(h), - d(new PrivateFramePrivate()) -{ +PrivateFrame::PrivateFrame(const ByteVector &data, Header *h) : Frame(h), + d(new PrivateFramePrivate()) { parseFields(fieldData(data)); } diff --git a/3rdparty/taglib/mpeg/id3v2/frames/privateframe.h b/3rdparty/taglib/mpeg/id3v2/frames/privateframe.h index dcaea11ce..add5d19e1 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/privateframe.h +++ b/3rdparty/taglib/mpeg/id3v2/frames/privateframe.h @@ -33,81 +33,80 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace ID3v2 { +namespace ID3v2 { - //! An implementation of ID3v2 privateframe +//! An implementation of ID3v2 privateframe - class TAGLIB_EXPORT PrivateFrame : public Frame - { - friend class FrameFactory; +class TAGLIB_EXPORT PrivateFrame : public Frame { + friend class FrameFactory; - public: - /*! + public: + /*! * Construct an empty private frame. */ - PrivateFrame(); + PrivateFrame(); - /*! + /*! * Construct a private frame based on the data in \a data. * * \note This is the constructor used when parsing the frame from a file. */ - explicit PrivateFrame(const ByteVector &data); + explicit PrivateFrame(const ByteVector &data); - /*! + /*! * Destroys this private frame instance. */ - virtual ~PrivateFrame(); + virtual ~PrivateFrame(); - /*! + /*! * Returns the text of this private frame, currently just the owner. * * \see text() */ - virtual String toString() const; + virtual String toString() const; - /*! + /*! * \return The owner of the private frame. * \note This should contain an email address or link to a website. */ - String owner() const; + String owner() const; - /*! + /*! * */ - ByteVector data() const; + ByteVector data() const; - /*! + /*! * Sets the owner of the frame to \a s. * \note This should contain an email address or link to a website. */ - void setOwner(const String &s); + void setOwner(const String &s); - /*! + /*! * */ - void setData(const ByteVector &v); + void setData(const ByteVector &v); - protected: - // Reimplementations. + protected: + // Reimplementations. - virtual void parseFields(const ByteVector &data); - virtual ByteVector renderFields() const; + virtual void parseFields(const ByteVector &data); + virtual ByteVector renderFields() const; - private: - /*! + private: + /*! * The constructor used by the FrameFactory. */ - PrivateFrame(const ByteVector &data, Header *h); + PrivateFrame(const ByteVector &data, Header *h); - PrivateFrame(const PrivateFrame &); - PrivateFrame &operator=(const PrivateFrame &); + PrivateFrame(const PrivateFrame &); + PrivateFrame &operator=(const PrivateFrame &); - class PrivateFramePrivate; - PrivateFramePrivate *d; - }; + class PrivateFramePrivate; + PrivateFramePrivate *d; +}; - } -} -} +} // namespace ID3v2 +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/id3v2/frames/relativevolumeframe.cpp b/3rdparty/taglib/mpeg/id3v2/frames/relativevolumeframe.cpp index 12f36fdfc..0cd67e31f 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/relativevolumeframe.cpp +++ b/3rdparty/taglib/mpeg/id3v2/frames/relativevolumeframe.cpp @@ -31,8 +31,7 @@ using namespace Strawberry_TagLib::TagLib; using namespace ID3v2; -struct ChannelData -{ +struct ChannelData { ChannelData() : channelType(RelativeVolumeFrame::Other), volumeAdjustment(0) {} RelativeVolumeFrame::ChannelType channelType; @@ -40,9 +39,8 @@ struct ChannelData RelativeVolumeFrame::PeakVolume peakVolume; }; -class RelativeVolumeFrame::RelativeVolumeFramePrivate -{ -public: +class RelativeVolumeFrame::RelativeVolumeFramePrivate { + public: String identification; Map channels; }; @@ -51,35 +49,28 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -RelativeVolumeFrame::RelativeVolumeFrame() : - Frame("RVA2"), - d(new RelativeVolumeFramePrivate()) -{ +RelativeVolumeFrame::RelativeVolumeFrame() : Frame("RVA2"), + d(new RelativeVolumeFramePrivate()) { } -RelativeVolumeFrame::RelativeVolumeFrame(const ByteVector &data) : - Frame(data), - d(new RelativeVolumeFramePrivate()) -{ +RelativeVolumeFrame::RelativeVolumeFrame(const ByteVector &data) : Frame(data), + d(new RelativeVolumeFramePrivate()) { setData(data); } -RelativeVolumeFrame::~RelativeVolumeFrame() -{ +RelativeVolumeFrame::~RelativeVolumeFrame() { delete d; } -String RelativeVolumeFrame::toString() const -{ +String RelativeVolumeFrame::toString() const { return d->identification; } -List RelativeVolumeFrame::channels() const -{ +List RelativeVolumeFrame::channels() const { List l; Map::ConstIterator it = d->channels.begin(); - for(; it != d->channels.end(); ++it) + for (; it != d->channels.end(); ++it) l.append((*it).first); return l; @@ -87,85 +78,68 @@ List RelativeVolumeFrame::channels() const // deprecated -RelativeVolumeFrame::ChannelType RelativeVolumeFrame::channelType() const -{ +RelativeVolumeFrame::ChannelType RelativeVolumeFrame::channelType() const { return MasterVolume; } // deprecated -void RelativeVolumeFrame::setChannelType(ChannelType) -{ - +void RelativeVolumeFrame::setChannelType(ChannelType) { } -short RelativeVolumeFrame::volumeAdjustmentIndex(ChannelType type) const -{ +short RelativeVolumeFrame::volumeAdjustmentIndex(ChannelType type) const { return d->channels.contains(type) ? d->channels[type].volumeAdjustment : 0; } -short RelativeVolumeFrame::volumeAdjustmentIndex() const -{ +short RelativeVolumeFrame::volumeAdjustmentIndex() const { return volumeAdjustmentIndex(MasterVolume); } -void RelativeVolumeFrame::setVolumeAdjustmentIndex(short index, ChannelType type) -{ +void RelativeVolumeFrame::setVolumeAdjustmentIndex(short index, ChannelType type) { d->channels[type].volumeAdjustment = index; } -void RelativeVolumeFrame::setVolumeAdjustmentIndex(short index) -{ +void RelativeVolumeFrame::setVolumeAdjustmentIndex(short index) { setVolumeAdjustmentIndex(index, MasterVolume); } -float RelativeVolumeFrame::volumeAdjustment(ChannelType type) const -{ +float RelativeVolumeFrame::volumeAdjustment(ChannelType type) const { return d->channels.contains(type) ? float(d->channels[type].volumeAdjustment) / float(512) : 0; } -float RelativeVolumeFrame::volumeAdjustment() const -{ +float RelativeVolumeFrame::volumeAdjustment() const { return volumeAdjustment(MasterVolume); } -void RelativeVolumeFrame::setVolumeAdjustment(float adjustment, ChannelType type) -{ +void RelativeVolumeFrame::setVolumeAdjustment(float adjustment, ChannelType type) { d->channels[type].volumeAdjustment = short(adjustment * float(512)); } -void RelativeVolumeFrame::setVolumeAdjustment(float adjustment) -{ +void RelativeVolumeFrame::setVolumeAdjustment(float adjustment) { setVolumeAdjustment(adjustment, MasterVolume); } -RelativeVolumeFrame::PeakVolume RelativeVolumeFrame::peakVolume(ChannelType type) const -{ +RelativeVolumeFrame::PeakVolume RelativeVolumeFrame::peakVolume(ChannelType type) const { return d->channels.contains(type) ? d->channels[type].peakVolume : PeakVolume(); } -RelativeVolumeFrame::PeakVolume RelativeVolumeFrame::peakVolume() const -{ +RelativeVolumeFrame::PeakVolume RelativeVolumeFrame::peakVolume() const { return peakVolume(MasterVolume); } -void RelativeVolumeFrame::setPeakVolume(const PeakVolume &peak, ChannelType type) -{ +void RelativeVolumeFrame::setPeakVolume(const PeakVolume &peak, ChannelType type) { d->channels[type].peakVolume = peak; } -void RelativeVolumeFrame::setPeakVolume(const PeakVolume &peak) -{ +void RelativeVolumeFrame::setPeakVolume(const PeakVolume &peak) { setPeakVolume(peak, MasterVolume); } -String RelativeVolumeFrame::identification() const -{ +String RelativeVolumeFrame::identification() const { return d->identification; } -void RelativeVolumeFrame::setIdentification(const String &s) -{ +void RelativeVolumeFrame::setIdentification(const String &s) { d->identification = s; } @@ -173,14 +147,13 @@ void RelativeVolumeFrame::setIdentification(const String &s) // protected members //////////////////////////////////////////////////////////////////////////////// -void RelativeVolumeFrame::parseFields(const ByteVector &data) -{ +void RelativeVolumeFrame::parseFields(const ByteVector &data) { int pos = 0; d->identification = readStringField(data, String::Latin1, &pos); // Each channel is at least 4 bytes. - while(pos <= (int)data.size() - 4) { + while (pos <= (int)data.size() - 4) { ChannelType type = ChannelType(data[pos]); pos += 1; @@ -199,8 +172,7 @@ void RelativeVolumeFrame::parseFields(const ByteVector &data) } } -ByteVector RelativeVolumeFrame::renderFields() const -{ +ByteVector RelativeVolumeFrame::renderFields() const { ByteVector data; data.append(d->identification.data(String::Latin1)); @@ -208,7 +180,7 @@ ByteVector RelativeVolumeFrame::renderFields() const Map::ConstIterator it = d->channels.begin(); - for(; it != d->channels.end(); ++it) { + for (; it != d->channels.end(); ++it) { ChannelType type = (*it).first; const ChannelData &channel = (*it).second; @@ -225,9 +197,7 @@ ByteVector RelativeVolumeFrame::renderFields() const // private members //////////////////////////////////////////////////////////////////////////////// -RelativeVolumeFrame::RelativeVolumeFrame(const ByteVector &data, Header *h) : - Frame(h), - d(new RelativeVolumeFramePrivate()) -{ +RelativeVolumeFrame::RelativeVolumeFrame(const ByteVector &data, Header *h) : Frame(h), + d(new RelativeVolumeFramePrivate()) { parseFields(fieldData(data)); } diff --git a/3rdparty/taglib/mpeg/id3v2/frames/relativevolumeframe.h b/3rdparty/taglib/mpeg/id3v2/frames/relativevolumeframe.h index cb53d7904..fb7947958 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/relativevolumeframe.h +++ b/3rdparty/taglib/mpeg/id3v2/frames/relativevolumeframe.h @@ -33,11 +33,11 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace ID3v2 { +namespace ID3v2 { - //! An ID3v2 relative volume adjustment frame implementation +//! An ID3v2 relative volume adjustment frame implementation - /*! +/*! * This is an implementation of ID3v2 relative volume adjustment. The * presence of this frame makes it possible to specify an increase in volume * for an audio file or specific audio tracks in that file. @@ -47,99 +47,96 @@ namespace TagLib { * different channel types. */ - class TAGLIB_EXPORT RelativeVolumeFrame : public Frame - { - friend class FrameFactory; +class TAGLIB_EXPORT RelativeVolumeFrame : public Frame { + friend class FrameFactory; - public: - - /*! + public: + /*! * This indicates the type of volume adjustment that should be applied. */ - enum ChannelType { - //! A type not enumerated below - Other = 0x00, - //! The master volume for the track - MasterVolume = 0x01, - //! The front right audio channel - FrontRight = 0x02, - //! The front left audio channel - FrontLeft = 0x03, - //! The back right audio channel - BackRight = 0x04, - //! The back left audio channel - BackLeft = 0x05, - //! The front center audio channel - FrontCentre = 0x06, - //! The back center audio channel - BackCentre = 0x07, - //! The subwoofer audio channel - Subwoofer = 0x08 - }; + enum ChannelType { + //! A type not enumerated below + Other = 0x00, + //! The master volume for the track + MasterVolume = 0x01, + //! The front right audio channel + FrontRight = 0x02, + //! The front left audio channel + FrontLeft = 0x03, + //! The back right audio channel + BackRight = 0x04, + //! The back left audio channel + BackLeft = 0x05, + //! The front center audio channel + FrontCentre = 0x06, + //! The back center audio channel + BackCentre = 0x07, + //! The subwoofer audio channel + Subwoofer = 0x08 + }; - //! Struct that stores the relevant values for ID3v2 peak volume + //! Struct that stores the relevant values for ID3v2 peak volume - /*! + /*! * The peak volume is described as a series of bits that is padded to fill * a block of bytes. These two values should always be updated in tandem. */ - struct PeakVolume - { - /*! + struct PeakVolume { + /*! * Constructs an empty peak volume description. */ - PeakVolume() : bitsRepresentingPeak(0) {} - /*! + PeakVolume() : bitsRepresentingPeak(0) {} + /*! * The number of bits (in the range of 0 to 255) used to describe the * peak volume. */ - unsigned char bitsRepresentingPeak; - /*! + unsigned char bitsRepresentingPeak; + /*! * The array of bits (represented as a series of bytes) used to describe * the peak volume. */ - ByteVector peakVolume; - }; + ByteVector peakVolume; + }; - /*! + /*! * Constructs a RelativeVolumeFrame. The relevant data should be set * manually. */ - RelativeVolumeFrame(); + RelativeVolumeFrame(); - /*! + /*! * Constructs a RelativeVolumeFrame based on the contents of \a data. */ - RelativeVolumeFrame(const ByteVector &data); + RelativeVolumeFrame(const ByteVector &data); - /*! + /*! * Destroys the RelativeVolumeFrame instance. */ - virtual ~RelativeVolumeFrame(); + virtual ~RelativeVolumeFrame(); - /*! + /*! * Returns the frame's identification. * * \see identification() */ - virtual String toString() const; + virtual String toString() const; - /*! + /*! * Returns a list of channels with information currently in the frame. */ - List channels() const; + List channels() const; - /*! + /*! * \deprecated Always returns master volume. */ - TAGLIB_DEPRECATED ChannelType channelType() const; + TAGLIB_DEPRECATED ChannelType channelType() const; - /*! + /*! * \deprecated This method no longer has any effect. */ - TAGLIB_DEPRECATED void setChannelType(ChannelType t); + TAGLIB_DEPRECATED void setChannelType(ChannelType t); - /* + /* * There was a terrible API goof here, and while this can't be changed to * the way it appears below for binary compatibility reasons, let's at * least pretend that it looks clean. @@ -147,7 +144,7 @@ namespace TagLib { #ifdef DOXYGEN - /*! + /*! * Returns the relative volume adjustment "index". As indicated by the * ID3v2 standard this is a 16-bit signed integer that reflects the * decibels of adjustment when divided by 512. @@ -158,9 +155,9 @@ namespace TagLib { * \see setVolumeAdjustmentIndex() * \see volumeAjustment() */ - short volumeAdjustmentIndex(ChannelType type = MasterVolume) const; + short volumeAdjustmentIndex(ChannelType type = MasterVolume) const; - /*! + /*! * Set the volume adjustment to \a index. As indicated by the ID3v2 * standard this is a 16-bit signed integer that reflects the decibels of * adjustment when divided by 512. @@ -170,9 +167,9 @@ namespace TagLib { * \see volumeAdjustmentIndex() * \see setVolumeAjustment() */ - void setVolumeAdjustmentIndex(short index, ChannelType type = MasterVolume); + void setVolumeAdjustmentIndex(short index, ChannelType type = MasterVolume); - /*! + /*! * Returns the relative volume adjustment in decibels. * * \note Because this is actually stored internally as an "index" to this @@ -185,9 +182,9 @@ namespace TagLib { * \see setVolumeAdjustment() * \see volumeAdjustmentIndex() */ - float volumeAdjustment(ChannelType type = MasterVolume) const; + float volumeAdjustment(ChannelType type = MasterVolume) const; - /*! + /*! * Set the relative volume adjustment in decibels to \a adjustment. * * By default this sets the value for the master volume. @@ -199,9 +196,9 @@ namespace TagLib { * \see setVolumeAdjustment() * \see volumeAdjustmentIndex() */ - void setVolumeAdjustment(float adjustment, ChannelType type = MasterVolume); + void setVolumeAdjustment(float adjustment, ChannelType type = MasterVolume); - /*! + /*! * Returns the peak volume (represented as a length and a string of bits). * * This defaults to returning the value for the master volume channel if @@ -209,68 +206,68 @@ namespace TagLib { * * \see setPeakVolume() */ - PeakVolume peakVolume(ChannelType type = MasterVolume) const; + PeakVolume peakVolume(ChannelType type = MasterVolume) const; - /*! + /*! * Sets the peak volume to \a peak. * * By default this sets the value for the master volume. * * \see peakVolume() */ - void setPeakVolume(const PeakVolume &peak, ChannelType type = MasterVolume); + void setPeakVolume(const PeakVolume &peak, ChannelType type = MasterVolume); #else - // BIC: Combine each of the following pairs of functions (or maybe just - // rework this junk altogether). + // BIC: Combine each of the following pairs of functions (or maybe just + // rework this junk altogether). - short volumeAdjustmentIndex(ChannelType type) const; - short volumeAdjustmentIndex() const; + short volumeAdjustmentIndex(ChannelType type) const; + short volumeAdjustmentIndex() const; - void setVolumeAdjustmentIndex(short index, ChannelType type); - void setVolumeAdjustmentIndex(short index); + void setVolumeAdjustmentIndex(short index, ChannelType type); + void setVolumeAdjustmentIndex(short index); - float volumeAdjustment(ChannelType type) const; - float volumeAdjustment() const; + float volumeAdjustment(ChannelType type) const; + float volumeAdjustment() const; - void setVolumeAdjustment(float adjustment, ChannelType type); - void setVolumeAdjustment(float adjustment); + void setVolumeAdjustment(float adjustment, ChannelType type); + void setVolumeAdjustment(float adjustment); - PeakVolume peakVolume(ChannelType type) const; - PeakVolume peakVolume() const; + PeakVolume peakVolume(ChannelType type) const; + PeakVolume peakVolume() const; - void setPeakVolume(const PeakVolume &peak, ChannelType type); - void setPeakVolume(const PeakVolume &peak); + void setPeakVolume(const PeakVolume &peak, ChannelType type); + void setPeakVolume(const PeakVolume &peak); #endif - /*! + /*! * Returns the identification for this frame. */ - String identification() const; + String identification() const; - /*! + /*! * Sets the identification of the frame to \a s. The string * is used to identify the situation and/or device where this * adjustment should apply. */ - void setIdentification(const String &s); + void setIdentification(const String &s); - protected: - virtual void parseFields(const ByteVector &data); - virtual ByteVector renderFields() const; + protected: + virtual void parseFields(const ByteVector &data); + virtual ByteVector renderFields() const; - private: - RelativeVolumeFrame(const ByteVector &data, Header *h); - RelativeVolumeFrame(const RelativeVolumeFrame &); - RelativeVolumeFrame &operator=(const RelativeVolumeFrame &); + private: + RelativeVolumeFrame(const ByteVector &data, Header *h); + RelativeVolumeFrame(const RelativeVolumeFrame &); + RelativeVolumeFrame &operator=(const RelativeVolumeFrame &); - class RelativeVolumeFramePrivate; - RelativeVolumeFramePrivate *d; - }; + class RelativeVolumeFramePrivate; + RelativeVolumeFramePrivate *d; +}; - } -} -} +} // namespace ID3v2 +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.cpp b/3rdparty/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.cpp index 6180ea466..6a53a855e 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.cpp +++ b/3rdparty/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.cpp @@ -32,13 +32,11 @@ using namespace Strawberry_TagLib::TagLib; using namespace ID3v2; -class SynchronizedLyricsFrame::SynchronizedLyricsFramePrivate -{ -public: - SynchronizedLyricsFramePrivate() : - textEncoding(String::Latin1), - timestampFormat(SynchronizedLyricsFrame::AbsoluteMilliseconds), - type(SynchronizedLyricsFrame::Lyrics) {} +class SynchronizedLyricsFrame::SynchronizedLyricsFramePrivate { + public: + SynchronizedLyricsFramePrivate() : textEncoding(String::Latin1), + timestampFormat(SynchronizedLyricsFrame::AbsoluteMilliseconds), + type(SynchronizedLyricsFrame::Lyrics) {} String::Type textEncoding; ByteVector language; SynchronizedLyricsFrame::TimestampFormat timestampFormat; @@ -51,90 +49,72 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -SynchronizedLyricsFrame::SynchronizedLyricsFrame(String::Type encoding) : - Frame("SYLT"), - d(new SynchronizedLyricsFramePrivate()) -{ +SynchronizedLyricsFrame::SynchronizedLyricsFrame(String::Type encoding) : Frame("SYLT"), + d(new SynchronizedLyricsFramePrivate()) { d->textEncoding = encoding; } -SynchronizedLyricsFrame::SynchronizedLyricsFrame(const ByteVector &data) : - Frame(data), - d(new SynchronizedLyricsFramePrivate()) -{ +SynchronizedLyricsFrame::SynchronizedLyricsFrame(const ByteVector &data) : Frame(data), + d(new SynchronizedLyricsFramePrivate()) { setData(data); } -SynchronizedLyricsFrame::~SynchronizedLyricsFrame() -{ +SynchronizedLyricsFrame::~SynchronizedLyricsFrame() { delete d; } -String SynchronizedLyricsFrame::toString() const -{ +String SynchronizedLyricsFrame::toString() const { return d->description; } -String::Type SynchronizedLyricsFrame::textEncoding() const -{ +String::Type SynchronizedLyricsFrame::textEncoding() const { return d->textEncoding; } -ByteVector SynchronizedLyricsFrame::language() const -{ +ByteVector SynchronizedLyricsFrame::language() const { return d->language; } SynchronizedLyricsFrame::TimestampFormat -SynchronizedLyricsFrame::timestampFormat() const -{ +SynchronizedLyricsFrame::timestampFormat() const { return d->timestampFormat; } -SynchronizedLyricsFrame::Type SynchronizedLyricsFrame::type() const -{ +SynchronizedLyricsFrame::Type SynchronizedLyricsFrame::type() const { return d->type; } -String SynchronizedLyricsFrame::description() const -{ +String SynchronizedLyricsFrame::description() const { return d->description; } SynchronizedLyricsFrame::SynchedTextList -SynchronizedLyricsFrame::synchedText() const -{ +SynchronizedLyricsFrame::synchedText() const { return d->synchedText; } -void SynchronizedLyricsFrame::setTextEncoding(String::Type encoding) -{ +void SynchronizedLyricsFrame::setTextEncoding(String::Type encoding) { d->textEncoding = encoding; } -void SynchronizedLyricsFrame::setLanguage(const ByteVector &languageEncoding) -{ +void SynchronizedLyricsFrame::setLanguage(const ByteVector &languageEncoding) { d->language = languageEncoding.mid(0, 3); } -void SynchronizedLyricsFrame::setTimestampFormat(SynchronizedLyricsFrame::TimestampFormat f) -{ +void SynchronizedLyricsFrame::setTimestampFormat(SynchronizedLyricsFrame::TimestampFormat f) { d->timestampFormat = f; } -void SynchronizedLyricsFrame::setType(SynchronizedLyricsFrame::Type t) -{ +void SynchronizedLyricsFrame::setType(SynchronizedLyricsFrame::Type t) { d->type = t; } -void SynchronizedLyricsFrame::setDescription(const String &s) -{ +void SynchronizedLyricsFrame::setDescription(const String &s) { d->description = s; } void SynchronizedLyricsFrame::setSynchedText( - const SynchronizedLyricsFrame::SynchedTextList &t) -{ + const SynchronizedLyricsFrame::SynchedTextList &t) { d->synchedText = t; } @@ -142,10 +122,9 @@ void SynchronizedLyricsFrame::setSynchedText( // protected members //////////////////////////////////////////////////////////////////////////////// -void SynchronizedLyricsFrame::parseFields(const ByteVector &data) -{ +void SynchronizedLyricsFrame::parseFields(const ByteVector &data) { const int end = data.size(); - if(end < 7) { + if (end < 7) { debug("A synchronized lyrics frame must contain at least 7 bytes."); return; } @@ -158,7 +137,7 @@ void SynchronizedLyricsFrame::parseFields(const ByteVector &data) int pos = 6; d->description = readStringField(data, d->textEncoding, &pos); - if(pos == 6) + if (pos == 6) return; /* @@ -169,27 +148,28 @@ void SynchronizedLyricsFrame::parseFields(const ByteVector &data) * case of strings without BOM so that readStringField() will work. */ String::Type encWithEndianness = d->textEncoding; - if(d->textEncoding == String::UTF16) { + if (d->textEncoding == String::UTF16) { unsigned short bom = data.toUShort(6, true); - if(bom == 0xfffe) { + if (bom == 0xfffe) { encWithEndianness = String::UTF16LE; - } else if(bom == 0xfeff) { + } + else if (bom == 0xfeff) { encWithEndianness = String::UTF16BE; } } d->synchedText.clear(); - while(pos < end) { + while (pos < end) { String::Type enc = d->textEncoding; // If a UTF16 string has no BOM, use the encoding found above. - if(enc == String::UTF16 && pos + 1 < end) { + if (enc == String::UTF16 && pos + 1 < end) { unsigned short bom = data.toUShort(pos, true); - if(bom != 0xfffe && bom != 0xfeff) { + if (bom != 0xfffe && bom != 0xfeff) { enc = encWithEndianness; } } String text = readStringField(data, enc, &pos); - if(pos + 4 > end) + if (pos + 4 > end) return; unsigned int time = data.toUInt(pos, true); @@ -199,16 +179,15 @@ void SynchronizedLyricsFrame::parseFields(const ByteVector &data) } } -ByteVector SynchronizedLyricsFrame::renderFields() const -{ +ByteVector SynchronizedLyricsFrame::renderFields() const { ByteVector v; String::Type encoding = d->textEncoding; encoding = checkTextEncoding(d->description, encoding); - for(SynchedTextList::ConstIterator it = d->synchedText.begin(); - it != d->synchedText.end(); - ++it) { + for (SynchedTextList::ConstIterator it = d->synchedText.begin(); + it != d->synchedText.end(); + ++it) { encoding = checkTextEncoding(it->text, encoding); } @@ -218,9 +197,9 @@ ByteVector SynchronizedLyricsFrame::renderFields() const v.append(char(d->type)); v.append(d->description.data(encoding)); v.append(textDelimiter(encoding)); - for(SynchedTextList::ConstIterator it = d->synchedText.begin(); - it != d->synchedText.end(); - ++it) { + for (SynchedTextList::ConstIterator it = d->synchedText.begin(); + it != d->synchedText.end(); + ++it) { const SynchedText &entry = *it; v.append(entry.text.data(encoding)); v.append(textDelimiter(encoding)); @@ -234,9 +213,7 @@ ByteVector SynchronizedLyricsFrame::renderFields() const // private members //////////////////////////////////////////////////////////////////////////////// -SynchronizedLyricsFrame::SynchronizedLyricsFrame(const ByteVector &data, Header *h) : - Frame(h), - d(new SynchronizedLyricsFramePrivate()) -{ +SynchronizedLyricsFrame::SynchronizedLyricsFrame(const ByteVector &data, Header *h) : Frame(h), + d(new SynchronizedLyricsFramePrivate()) { parseFields(fieldData(data)); } diff --git a/3rdparty/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.h b/3rdparty/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.h index 0bb1832a1..3ceeb641f 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.h +++ b/3rdparty/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.h @@ -32,94 +32,92 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace ID3v2 { +namespace ID3v2 { - //! ID3v2 synchronized lyrics frame - /*! +//! ID3v2 synchronized lyrics frame +/*! * An implementation of ID3v2 synchronized lyrics. */ - class TAGLIB_EXPORT SynchronizedLyricsFrame : public Frame - { - friend class FrameFactory; +class TAGLIB_EXPORT SynchronizedLyricsFrame : public Frame { + friend class FrameFactory; - public: - - /*! + public: + /*! * Specifies the timestamp format used. */ - enum TimestampFormat { - //! The timestamp is of unknown format. - Unknown = 0x00, - //! The timestamp represents the number of MPEG frames since - //! the beginning of the audio stream. - AbsoluteMpegFrames = 0x01, - //! The timestamp represents the number of milliseconds since - //! the beginning of the audio stream. - AbsoluteMilliseconds = 0x02 - }; + enum TimestampFormat { + //! The timestamp is of unknown format. + Unknown = 0x00, + //! The timestamp represents the number of MPEG frames since + //! the beginning of the audio stream. + AbsoluteMpegFrames = 0x01, + //! The timestamp represents the number of milliseconds since + //! the beginning of the audio stream. + AbsoluteMilliseconds = 0x02 + }; - /*! + /*! * Specifies the type of text contained. */ - enum Type { - //! The text is some other type of text. - Other = 0x00, - //! The text contains lyrical data. - Lyrics = 0x01, - //! The text contains a transcription. - TextTranscription = 0x02, - //! The text lists the movements in the piece. - Movement = 0x03, - //! The text describes events that occur. - Events = 0x04, - //! The text contains chord changes that occur in the music. - Chord = 0x05, - //! The text contains trivia or "pop up" information about the media. - Trivia = 0x06, - //! The text contains URLs for relevant webpages. - WebpageUrls = 0x07, - //! The text contains URLs for relevant images. - ImageUrls = 0x08 - }; + enum Type { + //! The text is some other type of text. + Other = 0x00, + //! The text contains lyrical data. + Lyrics = 0x01, + //! The text contains a transcription. + TextTranscription = 0x02, + //! The text lists the movements in the piece. + Movement = 0x03, + //! The text describes events that occur. + Events = 0x04, + //! The text contains chord changes that occur in the music. + Chord = 0x05, + //! The text contains trivia or "pop up" information about the media. + Trivia = 0x06, + //! The text contains URLs for relevant webpages. + WebpageUrls = 0x07, + //! The text contains URLs for relevant images. + ImageUrls = 0x08 + }; - /*! + /*! * Single entry of time stamp and lyrics text. */ - struct SynchedText { - SynchedText(unsigned int ms, String str) : time(ms), text(str) {} - unsigned int time; - String text; - }; + struct SynchedText { + SynchedText(unsigned int ms, String str) : time(ms), text(str) {} + unsigned int time; + String text; + }; - /*! + /*! * List of synchronized lyrics. */ - typedef Strawberry_TagLib::TagLib::List SynchedTextList; + typedef Strawberry_TagLib::TagLib::List SynchedTextList; - /*! + /*! * Construct an empty synchronized lyrics frame that will use the text * encoding \a encoding. */ - explicit SynchronizedLyricsFrame(String::Type encoding = String::Latin1); + explicit SynchronizedLyricsFrame(String::Type encoding = String::Latin1); - /*! + /*! * Construct a synchronized lyrics frame based on the data in \a data. */ - explicit SynchronizedLyricsFrame(const ByteVector &data); + explicit SynchronizedLyricsFrame(const ByteVector &data); - /*! + /*! * Destroys this SynchronizedLyricsFrame instance. */ - virtual ~SynchronizedLyricsFrame(); + virtual ~SynchronizedLyricsFrame(); - /*! + /*! * Returns the description of this synchronized lyrics frame. * * \see description() */ - virtual String toString() const; + virtual String toString() const; - /*! + /*! * Returns the text encoding that will be used in rendering this frame. * This defaults to the type that was either specified in the constructor * or read from the frame when parsed. @@ -127,9 +125,9 @@ namespace TagLib { * \see setTextEncoding() * \see render() */ - String::Type textEncoding() const; + String::Type textEncoding() const; - /*! + /*! * Returns the language encoding as a 3 byte encoding as specified by * ISO-639-2. * @@ -137,97 +135,97 @@ namespace TagLib { * * \see setLanguage() */ - ByteVector language() const; + ByteVector language() const; - /*! + /*! * Returns the timestamp format. */ - TimestampFormat timestampFormat() const; + TimestampFormat timestampFormat() const; - /*! + /*! * Returns the type of text contained. */ - Type type() const; + Type type() const; - /*! + /*! * Returns the description of this synchronized lyrics frame. * * \note Most taggers simply ignore this value. * * \see setDescription() */ - String description() const; + String description() const; - /*! + /*! * Returns the text with the time stamps. */ - SynchedTextList synchedText() const; + SynchedTextList synchedText() const; - /*! + /*! * Sets the text encoding to be used when rendering this frame to * \a encoding. * * \see textEncoding() * \see render() */ - void setTextEncoding(String::Type encoding); + void setTextEncoding(String::Type encoding); - /*! + /*! * Set the language using the 3 byte language code from * ISO-639-2 to * \a languageCode. * * \see language() */ - void setLanguage(const ByteVector &languageCode); + void setLanguage(const ByteVector &languageCode); - /*! + /*! * Set the timestamp format. * * \see timestampFormat() */ - void setTimestampFormat(TimestampFormat f); + void setTimestampFormat(TimestampFormat f); - /*! + /*! * Set the type of text contained. * * \see type() */ - void setType(Type t); + void setType(Type t); - /*! + /*! * Sets the description of the synchronized lyrics frame to \a s. * * \see description() */ - void setDescription(const String &s); + void setDescription(const String &s); - /*! + /*! * Sets the text with the time stamps. * * \see text() */ - void setSynchedText(const SynchedTextList &t); + void setSynchedText(const SynchedTextList &t); - protected: - // Reimplementations. + protected: + // Reimplementations. - virtual void parseFields(const ByteVector &data); - virtual ByteVector renderFields() const; + virtual void parseFields(const ByteVector &data); + virtual ByteVector renderFields() const; - private: - /*! + private: + /*! * The constructor used by the FrameFactory. */ - SynchronizedLyricsFrame(const ByteVector &data, Header *h); - SynchronizedLyricsFrame(const SynchronizedLyricsFrame &); - SynchronizedLyricsFrame &operator=(const SynchronizedLyricsFrame &); + SynchronizedLyricsFrame(const ByteVector &data, Header *h); + SynchronizedLyricsFrame(const SynchronizedLyricsFrame &); + SynchronizedLyricsFrame &operator=(const SynchronizedLyricsFrame &); - class SynchronizedLyricsFramePrivate; - SynchronizedLyricsFramePrivate *d; - }; + class SynchronizedLyricsFramePrivate; + SynchronizedLyricsFramePrivate *d; +}; - } -} -} +} // namespace ID3v2 +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/id3v2/frames/tableofcontentsframe.cpp b/3rdparty/taglib/mpeg/id3v2/frames/tableofcontentsframe.cpp index 4fe964711..1caf549db 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/tableofcontentsframe.cpp +++ b/3rdparty/taglib/mpeg/id3v2/frames/tableofcontentsframe.cpp @@ -32,14 +32,11 @@ using namespace Strawberry_TagLib::TagLib; using namespace ID3v2; -class TableOfContentsFrame::TableOfContentsFramePrivate -{ -public: - TableOfContentsFramePrivate() : - tagHeader(0), - isTopLevel(false), - isOrdered(false) - { +class TableOfContentsFrame::TableOfContentsFramePrivate { + public: + TableOfContentsFramePrivate() : tagHeader(0), + isTopLevel(false), + isOrdered(false) { embeddedFrameList.setAutoDelete(true); } @@ -54,146 +51,122 @@ public: namespace { - // These functions are needed to try to aim for backward compatibility with - // an API that previously (unreasonably) required null bytes to be appended - // at the end of identifiers explicitly by the API user. +// These functions are needed to try to aim for backward compatibility with +// an API that previously (unreasonably) required null bytes to be appended +// at the end of identifiers explicitly by the API user. - // BIC: remove these +// BIC: remove these - ByteVector &strip(ByteVector &b) - { - if(b.endsWith('\0')) - b.resize(b.size() - 1); - return b; - } - - ByteVectorList &strip(ByteVectorList &l) - { - for(ByteVectorList::Iterator it = l.begin(); it != l.end(); ++it) - { - strip(*it); - } - return l; - } +ByteVector &strip(ByteVector &b) { + if (b.endsWith('\0')) + b.resize(b.size() - 1); + return b; } +ByteVectorList &strip(ByteVectorList &l) { + for (ByteVectorList::Iterator it = l.begin(); it != l.end(); ++it) { + strip(*it); + } + return l; +} +} // namespace + //////////////////////////////////////////////////////////////////////////////// // public methods //////////////////////////////////////////////////////////////////////////////// -TableOfContentsFrame::TableOfContentsFrame(const ID3v2::Header *tagHeader, const ByteVector &data) : - ID3v2::Frame(data), - d(new TableOfContentsFramePrivate()) -{ +TableOfContentsFrame::TableOfContentsFrame(const ID3v2::Header *tagHeader, const ByteVector &data) : ID3v2::Frame(data), + d(new TableOfContentsFramePrivate()) { d->tagHeader = tagHeader; setData(data); } TableOfContentsFrame::TableOfContentsFrame(const ByteVector &elementID, - const ByteVectorList &children, - const FrameList &embeddedFrames) : - ID3v2::Frame("CTOC"), - d(new TableOfContentsFramePrivate()) -{ + const ByteVectorList &children, + const FrameList &embeddedFrames) : ID3v2::Frame("CTOC"), + d(new TableOfContentsFramePrivate()) { d->elementID = elementID; strip(d->elementID); d->childElements = children; - for(FrameList::ConstIterator it = embeddedFrames.begin(); it != embeddedFrames.end(); ++it) + for (FrameList::ConstIterator it = embeddedFrames.begin(); it != embeddedFrames.end(); ++it) addEmbeddedFrame(*it); } -TableOfContentsFrame::~TableOfContentsFrame() -{ +TableOfContentsFrame::~TableOfContentsFrame() { delete d; } -ByteVector TableOfContentsFrame::elementID() const -{ +ByteVector TableOfContentsFrame::elementID() const { return d->elementID; } -bool TableOfContentsFrame::isTopLevel() const -{ +bool TableOfContentsFrame::isTopLevel() const { return d->isTopLevel; } -bool TableOfContentsFrame::isOrdered() const -{ +bool TableOfContentsFrame::isOrdered() const { return d->isOrdered; } -unsigned int TableOfContentsFrame::entryCount() const -{ +unsigned int TableOfContentsFrame::entryCount() const { return d->childElements.size(); } -ByteVectorList TableOfContentsFrame::childElements() const -{ +ByteVectorList TableOfContentsFrame::childElements() const { return d->childElements; } -void TableOfContentsFrame::setElementID(const ByteVector &eID) -{ +void TableOfContentsFrame::setElementID(const ByteVector &eID) { d->elementID = eID; strip(d->elementID); } -void TableOfContentsFrame::setIsTopLevel(const bool &t) -{ +void TableOfContentsFrame::setIsTopLevel(const bool &t) { d->isTopLevel = t; } -void TableOfContentsFrame::setIsOrdered(const bool &o) -{ +void TableOfContentsFrame::setIsOrdered(const bool &o) { d->isOrdered = o; } -void TableOfContentsFrame::setChildElements(const ByteVectorList &l) -{ +void TableOfContentsFrame::setChildElements(const ByteVectorList &l) { d->childElements = l; strip(d->childElements); } -void TableOfContentsFrame::addChildElement(const ByteVector &cE) -{ +void TableOfContentsFrame::addChildElement(const ByteVector &cE) { d->childElements.append(cE); strip(d->childElements); } -void TableOfContentsFrame::removeChildElement(const ByteVector &cE) -{ +void TableOfContentsFrame::removeChildElement(const ByteVector &cE) { ByteVectorList::Iterator it = d->childElements.find(cE); - if(it == d->childElements.end()) + if (it == d->childElements.end()) it = d->childElements.find(cE + ByteVector("\0")); d->childElements.erase(it); } -const FrameListMap &TableOfContentsFrame::embeddedFrameListMap() const -{ +const FrameListMap &TableOfContentsFrame::embeddedFrameListMap() const { return d->embeddedFrameListMap; } -const FrameList &TableOfContentsFrame::embeddedFrameList() const -{ +const FrameList &TableOfContentsFrame::embeddedFrameList() const { return d->embeddedFrameList; } -const FrameList &TableOfContentsFrame::embeddedFrameList(const ByteVector &frameID) const -{ +const FrameList &TableOfContentsFrame::embeddedFrameList(const ByteVector &frameID) const { return d->embeddedFrameListMap[frameID]; } -void TableOfContentsFrame::addEmbeddedFrame(Frame *frame) -{ +void TableOfContentsFrame::addEmbeddedFrame(Frame *frame) { d->embeddedFrameList.append(frame); d->embeddedFrameListMap[frame->frameID()].append(frame); } -void TableOfContentsFrame::removeEmbeddedFrame(Frame *frame, bool del) -{ +void TableOfContentsFrame::removeEmbeddedFrame(Frame *frame, bool del) { // remove the frame from the frame list FrameList::Iterator it = d->embeddedFrameList.find(frame); d->embeddedFrameList.erase(it); @@ -203,31 +176,30 @@ void TableOfContentsFrame::removeEmbeddedFrame(Frame *frame, bool del) d->embeddedFrameListMap[frame->frameID()].erase(it); // ...and delete as desired - if(del) + if (del) delete frame; } -void TableOfContentsFrame::removeEmbeddedFrames(const ByteVector &id) -{ +void TableOfContentsFrame::removeEmbeddedFrames(const ByteVector &id) { FrameList l = d->embeddedFrameListMap[id]; - for(FrameList::ConstIterator it = l.begin(); it != l.end(); ++it) + for (FrameList::ConstIterator it = l.begin(); it != l.end(); ++it) removeEmbeddedFrame(*it, true); } -String TableOfContentsFrame::toString() const -{ +String TableOfContentsFrame::toString() const { String s = String(d->elementID) + - ": top level: " + (d->isTopLevel ? "true" : "false") + - ", ordered: " + (d->isOrdered ? "true" : "false"); + ": top level: " + (d->isTopLevel ? "true" : "false") + + ", ordered: " + (d->isOrdered ? "true" : "false"); - if(!d->childElements.isEmpty()) { - s+= ", chapters: [ " + String(d->childElements.toByteVector(", ")) + " ]"; + if (!d->childElements.isEmpty()) { + s += ", chapters: [ " + String(d->childElements.toByteVector(", ")) + " ]"; } - if(!d->embeddedFrameList.isEmpty()) { + if (!d->embeddedFrameList.isEmpty()) { StringList frameIDs; - for(FrameList::ConstIterator it = d->embeddedFrameList.begin(); - it != d->embeddedFrameList.end(); ++it) + for (FrameList::ConstIterator it = d->embeddedFrameList.begin(); + it != d->embeddedFrameList.end(); + ++it) frameIDs.append((*it)->frameID()); s += ", sub-frames: [ " + frameIDs.toString(", ") + " ]"; } @@ -235,8 +207,7 @@ String TableOfContentsFrame::toString() const return s; } -PropertyMap TableOfContentsFrame::asProperties() const -{ +PropertyMap TableOfContentsFrame::asProperties() const { PropertyMap map; map.unsupportedData().append(frameID() + String("/") + d->elementID); @@ -245,42 +216,39 @@ PropertyMap TableOfContentsFrame::asProperties() const } TableOfContentsFrame *TableOfContentsFrame::findByElementID(const ID3v2::Tag *tag, - const ByteVector &eID) // static + const ByteVector &eID) // static { ID3v2::FrameList tablesOfContents = tag->frameList("CTOC"); - for(ID3v2::FrameList::ConstIterator it = tablesOfContents.begin(); - it != tablesOfContents.end(); - ++it) - { + for (ID3v2::FrameList::ConstIterator it = tablesOfContents.begin(); + it != tablesOfContents.end(); + ++it) { TableOfContentsFrame *frame = dynamic_cast(*it); - if(frame && frame->elementID() == eID) + if (frame && frame->elementID() == eID) return frame; } return nullptr; } -TableOfContentsFrame *TableOfContentsFrame::findTopLevel(const ID3v2::Tag *tag) // static +TableOfContentsFrame *TableOfContentsFrame::findTopLevel(const ID3v2::Tag *tag) // static { ID3v2::FrameList tablesOfContents = tag->frameList("CTOC"); - for(ID3v2::FrameList::ConstIterator it = tablesOfContents.begin(); - it != tablesOfContents.end(); - ++it) - { + for (ID3v2::FrameList::ConstIterator it = tablesOfContents.begin(); + it != tablesOfContents.end(); + ++it) { TableOfContentsFrame *frame = dynamic_cast(*it); - if(frame && frame->isTopLevel() == true) + if (frame && frame->isTopLevel() == true) return frame; } return nullptr; } -void TableOfContentsFrame::parseFields(const ByteVector &data) -{ +void TableOfContentsFrame::parseFields(const ByteVector &data) { unsigned int size = data.size(); - if(size < 6) { + if (size < 6) { debug("A CTOC frame must contain at least 6 bytes (1 byte element ID terminated by " "null, 1 byte flags, 1 byte entry count and 1 byte child element ID terminated " "by null."); @@ -293,24 +261,24 @@ void TableOfContentsFrame::parseFields(const ByteVector &data) d->isTopLevel = (data.at(pos) & 2) != 0; d->isOrdered = (data.at(pos++) & 1) != 0; unsigned int entryCount = static_cast(data.at(pos++)); - for(unsigned int i = 0; i < entryCount; i++) { + for (unsigned int i = 0; i < entryCount; i++) { ByteVector childElementID = readStringField(data, String::Latin1, &pos).data(String::Latin1); d->childElements.append(childElementID); } size -= pos; - if(size < header()->size()) + if (size < header()->size()) return; - while(embPos < size - header()->size()) { + while (embPos < size - header()->size()) { Frame *frame = FrameFactory::instance()->createFrame(data.mid(pos + embPos), d->tagHeader); - if(!frame) + if (!frame) return; // Checks to make sure that frame parsed correctly. - if(frame->size() <= 0) { + if (frame->size() <= 0) { delete frame; return; } @@ -320,16 +288,15 @@ void TableOfContentsFrame::parseFields(const ByteVector &data) } } -ByteVector TableOfContentsFrame::renderFields() const -{ +ByteVector TableOfContentsFrame::renderFields() const { ByteVector data; data.append(d->elementID); data.append('\0'); char flags = 0; - if(d->isTopLevel) + if (d->isTopLevel) flags += 2; - if(d->isOrdered) + if (d->isOrdered) flags += 1; data.append(flags); data.append((char)(entryCount())); @@ -347,10 +314,8 @@ ByteVector TableOfContentsFrame::renderFields() const } TableOfContentsFrame::TableOfContentsFrame(const ID3v2::Header *tagHeader, - const ByteVector &data, Header *h) : - Frame(h), - d(new TableOfContentsFramePrivate()) -{ + const ByteVector &data, Header *h) : Frame(h), + d(new TableOfContentsFramePrivate()) { d->tagHeader = tagHeader; parseFields(fieldData(data)); } diff --git a/3rdparty/taglib/mpeg/id3v2/frames/tableofcontentsframe.h b/3rdparty/taglib/mpeg/id3v2/frames/tableofcontentsframe.h index ba21eda0a..26cbf3ce5 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/tableofcontentsframe.h +++ b/3rdparty/taglib/mpeg/id3v2/frames/tableofcontentsframe.h @@ -34,125 +34,124 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace ID3v2 { +namespace ID3v2 { - /*! +/*! * This is an implementation of ID3v2 table of contents frames. Purpose * of this frame is to allow a table of contents to be defined. */ - //! An implementation of ID3v2 table of contents frames +//! An implementation of ID3v2 table of contents frames - class TAGLIB_EXPORT TableOfContentsFrame : public ID3v2::Frame - { - friend class FrameFactory; +class TAGLIB_EXPORT TableOfContentsFrame : public ID3v2::Frame { + friend class FrameFactory; - public: - /*! + public: + /*! * Creates a table of contents frame based on \a data. \a tagHeader is * required as the internal frames are parsed based on the tag version. */ - TableOfContentsFrame(const ID3v2::Header *tagHeader, const ByteVector &data); + TableOfContentsFrame(const ID3v2::Header *tagHeader, const ByteVector &data); - /*! + /*! * Creates a table of contents frame with the element ID \a elementID, * the child elements \a children and embedded frames, which become owned * by this frame, in \a embeddedFrames. */ - TableOfContentsFrame(const ByteVector &elementID, - const ByteVectorList &children = ByteVectorList(), - const FrameList &embeddedFrames = FrameList()); + TableOfContentsFrame(const ByteVector &elementID, + const ByteVectorList &children = ByteVectorList(), + const FrameList &embeddedFrames = FrameList()); - /*! + /*! * Destroys the frame. */ - ~TableOfContentsFrame(); + ~TableOfContentsFrame(); - /*! + /*! * Returns the elementID of the frame. Element ID * is a null terminated string, however it's not human-readable. * * \see setElementID() */ - ByteVector elementID() const; + ByteVector elementID() const; - /*! + /*! * Returns true, if the frame is top-level (doesn't have * any parent CTOC frame). * * \see setIsTopLevel() */ - bool isTopLevel() const; + bool isTopLevel() const; - /*! + /*! * Returns true, if the child elements list entries * are ordered. * * \see setIsOrdered() */ - bool isOrdered() const; + bool isOrdered() const; - /*! + /*! * Returns count of child elements of the frame. It always * corresponds to size of child elements list. * * \see childElements() */ - unsigned int entryCount() const; + unsigned int entryCount() const; - /*! + /*! * Returns list of child elements of the frame. * * \see setChildElements() */ - ByteVectorList childElements() const; + ByteVectorList childElements() const; - /*! + /*! * Sets the elementID of the frame to \a eID. If \a eID isn't * null terminated, a null char is appended automatically. * * \see elementID() */ - void setElementID(const ByteVector &eID); + void setElementID(const ByteVector &eID); - /*! + /*! * Sets, if the frame is top-level (doesn't have * any parent CTOC frame). * * \see isTopLevel() */ - void setIsTopLevel(const bool &t); + void setIsTopLevel(const bool &t); - /*! + /*! * Sets, if the child elements list entries * are ordered. * * \see isOrdered() */ - void setIsOrdered(const bool &o); + void setIsOrdered(const bool &o); - /*! + /*! * Sets list of child elements of the frame to \a l. * * \see childElements() */ - void setChildElements(const ByteVectorList &l); + void setChildElements(const ByteVectorList &l); - /*! + /*! * Adds \a cE to list of child elements of the frame. * * \see childElements() */ - void addChildElement(const ByteVector &cE); + void addChildElement(const ByteVector &cE); - /*! + /*! * Removes \a cE to list of child elements of the frame. * * \see childElements() */ - void removeChildElement(const ByteVector &cE); + void removeChildElement(const ByteVector &cE); - /*! + /*! * Returns a reference to the frame list map. This is an FrameListMap of * all of the frames embedded in the CTOC frame. * @@ -166,9 +165,9 @@ namespace TagLib { * * \see embeddedFrameList() */ - const FrameListMap &embeddedFrameListMap() const; + const FrameListMap &embeddedFrameListMap() const; - /*! + /*! * Returns a reference to the embedded frame list. This is an FrameList * of all of the frames embedded in the CTOC frame in the order that they * were parsed. @@ -179,9 +178,9 @@ namespace TagLib { * \warning You should not modify this data structure directly, instead * use addEmbeddedFrame() and removeEmbeddedFrame(). */ - const FrameList &embeddedFrameList() const; + const FrameList &embeddedFrameList() const; - /*! + /*! * Returns the embedded frame list for frames with the id \a frameID * or an empty list if there are no embedded frames of that type. This * is just a convenience and is equivalent to: @@ -192,71 +191,71 @@ namespace TagLib { * * \see embeddedFrameListMap() */ - const FrameList &embeddedFrameList(const ByteVector &frameID) const; + const FrameList &embeddedFrameList(const ByteVector &frameID) const; - /*! + /*! * Add an embedded frame to the CTOC frame. At this point the CTOC frame * takes ownership of the embedded frame and will handle freeing its memory. * * \note Using this method will invalidate any pointers on the list * returned by embeddedFrameList() */ - void addEmbeddedFrame(Frame *frame); + void addEmbeddedFrame(Frame *frame); - /*! + /*! * Remove an embedded frame from the CTOC frame. If \a del is true the frame's * memory will be freed; if it is false, it must be deleted by the user. * * \note Using this method will invalidate any pointers on the list * returned by embeddedFrameList() */ - void removeEmbeddedFrame(Frame *frame, bool del = true); + void removeEmbeddedFrame(Frame *frame, bool del = true); - /*! + /*! * Remove all embedded frames of type \a id from the CTOC frame and free their * memory. * * \note Using this method will invalidate any pointers on the list * returned by embeddedFrameList() */ - void removeEmbeddedFrames(const ByteVector &id); + void removeEmbeddedFrames(const ByteVector &id); - virtual String toString() const; + virtual String toString() const; - PropertyMap asProperties() const; + PropertyMap asProperties() const; - /*! + /*! * CTOC frames each have a unique element ID. This searches for a CTOC * frame with the element ID \a eID and returns a pointer to it. This * can be used to link together parent and child CTOC frames. * * \see elementID() */ - static TableOfContentsFrame *findByElementID(const Tag *tag, const ByteVector &eID); + static TableOfContentsFrame *findByElementID(const Tag *tag, const ByteVector &eID); - /*! + /*! * CTOC frames each contain a flag that indicates, if CTOC frame is top-level (there isn't * any frame, which contains this frame in its child elements list). Only a single frame * within tag can be top-level. This searches for a top-level CTOC frame. * * \see isTopLevel() */ - static TableOfContentsFrame *findTopLevel(const Tag *tag); + static TableOfContentsFrame *findTopLevel(const Tag *tag); - protected: - virtual void parseFields(const ByteVector &data); - virtual ByteVector renderFields() const; + protected: + virtual void parseFields(const ByteVector &data); + virtual ByteVector renderFields() const; - private: - TableOfContentsFrame(const ID3v2::Header *tagHeader, const ByteVector &data, Header *h); - TableOfContentsFrame(const TableOfContentsFrame &); - TableOfContentsFrame &operator=(const TableOfContentsFrame &); + private: + TableOfContentsFrame(const ID3v2::Header *tagHeader, const ByteVector &data, Header *h); + TableOfContentsFrame(const TableOfContentsFrame &); + TableOfContentsFrame &operator=(const TableOfContentsFrame &); - class TableOfContentsFramePrivate; - TableOfContentsFramePrivate *d; - }; - } -} -} + class TableOfContentsFramePrivate; + TableOfContentsFramePrivate *d; +}; +} // namespace ID3v2 +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/id3v2/frames/textidentificationframe.cpp b/3rdparty/taglib/mpeg/id3v2/frames/textidentificationframe.cpp index 9e80e0834..8376ad3d1 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/textidentificationframe.cpp +++ b/3rdparty/taglib/mpeg/id3v2/frames/textidentificationframe.cpp @@ -32,9 +32,8 @@ using namespace Strawberry_TagLib::TagLib; using namespace ID3v2; -class TextIdentificationFrame::TextIdentificationFramePrivate -{ -public: +class TextIdentificationFrame::TextIdentificationFramePrivate { + public: TextIdentificationFramePrivate() : textEncoding(String::Latin1) {} String::Type textEncoding; StringList fieldList; @@ -44,38 +43,34 @@ public: // TextIdentificationFrame public members //////////////////////////////////////////////////////////////////////////////// -TextIdentificationFrame::TextIdentificationFrame(const ByteVector &type, String::Type encoding) : - Frame(type), - d(new TextIdentificationFramePrivate()) -{ +TextIdentificationFrame::TextIdentificationFrame(const ByteVector &type, String::Type encoding) : Frame(type), + d(new TextIdentificationFramePrivate()) { d->textEncoding = encoding; } -TextIdentificationFrame::TextIdentificationFrame(const ByteVector &data) : - Frame(data), - d(new TextIdentificationFramePrivate()) -{ +TextIdentificationFrame::TextIdentificationFrame(const ByteVector &data) : Frame(data), + d(new TextIdentificationFramePrivate()) { setData(data); } -TextIdentificationFrame *TextIdentificationFrame::createTIPLFrame(const PropertyMap &properties) // static +TextIdentificationFrame *TextIdentificationFrame::createTIPLFrame(const PropertyMap &properties) // static { TextIdentificationFrame *frame = new TextIdentificationFrame("TIPL"); StringList l; - for(PropertyMap::ConstIterator it = properties.begin(); it != properties.end(); ++it){ + for (PropertyMap::ConstIterator it = properties.begin(); it != properties.end(); ++it) { l.append(it->first); - l.append(it->second.toString(",")); // comma-separated list of names + l.append(it->second.toString(",")); // comma-separated list of names } frame->setText(l); return frame; } -TextIdentificationFrame *TextIdentificationFrame::createTMCLFrame(const PropertyMap &properties) // static +TextIdentificationFrame *TextIdentificationFrame::createTMCLFrame(const PropertyMap &properties) // static { TextIdentificationFrame *frame = new TextIdentificationFrame("TMCL"); StringList l; - for(PropertyMap::ConstIterator it = properties.begin(); it != properties.end(); ++it){ - if(!it->first.startsWith(instrumentPrefix)) // should not happen + for (PropertyMap::ConstIterator it = properties.begin(); it != properties.end(); ++it) { + if (!it->first.startsWith(instrumentPrefix)) // should not happen continue; l.append(it->first.substr(instrumentPrefix.size())); l.append(it->second.toString(",")); @@ -84,92 +79,84 @@ TextIdentificationFrame *TextIdentificationFrame::createTMCLFrame(const Property return frame; } -TextIdentificationFrame::~TextIdentificationFrame() -{ +TextIdentificationFrame::~TextIdentificationFrame() { delete d; } -void TextIdentificationFrame::setText(const StringList &l) -{ +void TextIdentificationFrame::setText(const StringList &l) { d->fieldList = l; } -void TextIdentificationFrame::setText(const String &s) -{ +void TextIdentificationFrame::setText(const String &s) { d->fieldList = s; } -String TextIdentificationFrame::toString() const -{ +String TextIdentificationFrame::toString() const { return d->fieldList.toString(); } -StringList TextIdentificationFrame::fieldList() const -{ +StringList TextIdentificationFrame::fieldList() const { return d->fieldList; } -String::Type TextIdentificationFrame::textEncoding() const -{ +String::Type TextIdentificationFrame::textEncoding() const { return d->textEncoding; } -void TextIdentificationFrame::setTextEncoding(String::Type encoding) -{ +void TextIdentificationFrame::setTextEncoding(String::Type encoding) { d->textEncoding = encoding; } -namespace -{ - // array of allowed TIPL prefixes and their corresponding key value - const char* involvedPeople[][2] = { - {"ARRANGER", "ARRANGER"}, - {"ENGINEER", "ENGINEER"}, - {"PRODUCER", "PRODUCER"}, - {"DJ-MIX", "DJMIXER"}, - {"MIX", "MIXER"}, - }; - const size_t involvedPeopleSize = sizeof(involvedPeople) / sizeof(involvedPeople[0]); -} +namespace { +// array of allowed TIPL prefixes and their corresponding key value +const char *involvedPeople[][2] = { + { "ARRANGER", "ARRANGER" }, + { "ENGINEER", "ENGINEER" }, + { "PRODUCER", "PRODUCER" }, + { "DJ-MIX", "DJMIXER" }, + { "MIX", "MIXER" }, +}; +const size_t involvedPeopleSize = sizeof(involvedPeople) / sizeof(involvedPeople[0]); +} // namespace -const KeyConversionMap &TextIdentificationFrame::involvedPeopleMap() // static +const KeyConversionMap &TextIdentificationFrame::involvedPeopleMap() // static { static KeyConversionMap m; - if(m.isEmpty()) { - for(size_t i = 0; i < involvedPeopleSize; ++i) + if (m.isEmpty()) { + for (size_t i = 0; i < involvedPeopleSize; ++i) m.insert(involvedPeople[i][1], involvedPeople[i][0]); } return m; } -PropertyMap TextIdentificationFrame::asProperties() const -{ - if(frameID() == "TIPL") +PropertyMap TextIdentificationFrame::asProperties() const { + if (frameID() == "TIPL") return makeTIPLProperties(); - if(frameID() == "TMCL") + if (frameID() == "TMCL") return makeTMCLProperties(); PropertyMap map; String tagName = frameIDToKey(frameID()); - if(tagName.isEmpty()) { + if (tagName.isEmpty()) { map.unsupportedData().append(frameID()); return map; } StringList values = fieldList(); - if(tagName == "GENRE") { + if (tagName == "GENRE") { // Special case: Support ID3v1-style genre numbers. They are not officially supported in // ID3v2, however it seems that still a lot of programs use them. - for(StringList::Iterator it = values.begin(); it != values.end(); ++it) { + for (StringList::Iterator it = values.begin(); it != values.end(); ++it) { bool ok = false; - int test = it->toInt(&ok); // test if the genre value is an integer - if(ok) + int test = it->toInt(&ok); // test if the genre value is an integer + if (ok) *it = ID3v1::genre(test); } - } else if(tagName == "DATE") { - for(StringList::Iterator it = values.begin(); it != values.end(); ++it) { + } + else if (tagName == "DATE") { + for (StringList::Iterator it = values.begin(); it != values.end(); ++it) { // ID3v2 specifies ISO8601 timestamps which contain a 'T' as separator between date and time. // Since this is unusual in other formats, the T is removed. int tpos = it->find("T"); - if(tpos != -1) + if (tpos != -1) (*it)[tpos] = ' '; } } @@ -182,11 +169,10 @@ PropertyMap TextIdentificationFrame::asProperties() const // TextIdentificationFrame protected members //////////////////////////////////////////////////////////////////////////////// -void TextIdentificationFrame::parseFields(const ByteVector &data) -{ +void TextIdentificationFrame::parseFields(const ByteVector &data) { // Don't try to parse invalid frames - if(data.size() < 2) + if (data.size() < 2) return; // read the string data type (the first byte of the field data) @@ -202,10 +188,10 @@ void TextIdentificationFrame::parseFields(const ByteVector &data) int dataLength = data.size() - 1; - while(dataLength > 0 && data[dataLength] == 0) + while (dataLength > 0 && data[dataLength] == 0) dataLength--; - while(dataLength % byteAlign != 0) + while (dataLength % byteAlign != 0) dataLength++; ByteVectorList l = ByteVectorList::split(data.mid(1, dataLength), textDelimiter(d->textEncoding), byteAlign); @@ -215,9 +201,9 @@ void TextIdentificationFrame::parseFields(const ByteVector &data) // append those split values to the list and make sure that the new string's // type is the same specified for this frame - for(ByteVectorList::ConstIterator it = l.begin(); it != l.end(); it++) { - if(!(*it).isEmpty()) { - if(d->textEncoding == String::Latin1) + for (ByteVectorList::ConstIterator it = l.begin(); it != l.end(); it++) { + if (!(*it).isEmpty()) { + if (d->textEncoding == String::Latin1) d->fieldList.append(Tag::latin1StringHandler()->parse(*it)); else d->fieldList.append(String(*it, d->textEncoding)); @@ -225,21 +211,20 @@ void TextIdentificationFrame::parseFields(const ByteVector &data) } } -ByteVector TextIdentificationFrame::renderFields() const -{ +ByteVector TextIdentificationFrame::renderFields() const { String::Type encoding = checkTextEncoding(d->fieldList, d->textEncoding); ByteVector v; v.append(char(encoding)); - for(StringList::ConstIterator it = d->fieldList.begin(); it != d->fieldList.end(); it++) { + for (StringList::ConstIterator it = d->fieldList.begin(); it != d->fieldList.end(); it++) { // Since the field list is null delimited, if this is not the first // element in the list, append the appropriate delimiter for this // encoding. - if(it != d->fieldList.begin()) + if (it != d->fieldList.begin()) v.append(textDelimiter(encoding)); v.append((*it).data(encoding)); @@ -252,31 +237,28 @@ ByteVector TextIdentificationFrame::renderFields() const // TextIdentificationFrame private members //////////////////////////////////////////////////////////////////////////////// -TextIdentificationFrame::TextIdentificationFrame(const ByteVector &data, Header *h) : - Frame(h), - d(new TextIdentificationFramePrivate()) -{ +TextIdentificationFrame::TextIdentificationFrame(const ByteVector &data, Header *h) : Frame(h), + d(new TextIdentificationFramePrivate()) { parseFields(fieldData(data)); } -PropertyMap TextIdentificationFrame::makeTIPLProperties() const -{ +PropertyMap TextIdentificationFrame::makeTIPLProperties() const { PropertyMap map; - if(fieldList().size() % 2 != 0){ + if (fieldList().size() % 2 != 0) { // according to the ID3 spec, TIPL must contain an even number of entries map.unsupportedData().append(frameID()); return map; } StringList l = fieldList(); - for(StringList::ConstIterator it = l.begin(); it != l.end(); ++it) { + for (StringList::ConstIterator it = l.begin(); it != l.end(); ++it) { bool found = false; - for(size_t i = 0; i < involvedPeopleSize; ++i) - if(*it == involvedPeople[i][0]) { + for (size_t i = 0; i < involvedPeopleSize; ++i) + if (*it == involvedPeople[i][0]) { map.insert(involvedPeople[i][1], (++it)->split(",")); found = true; break; } - if(!found){ + if (!found) { // invalid involved role -> mark whole frame as unsupported in order to be consistent with writing map.clear(); map.unsupportedData().append(frameID()); @@ -286,18 +268,17 @@ PropertyMap TextIdentificationFrame::makeTIPLProperties() const return map; } -PropertyMap TextIdentificationFrame::makeTMCLProperties() const -{ +PropertyMap TextIdentificationFrame::makeTMCLProperties() const { PropertyMap map; - if(fieldList().size() % 2 != 0){ + if (fieldList().size() % 2 != 0) { // according to the ID3 spec, TMCL must contain an even number of entries map.unsupportedData().append(frameID()); return map; } StringList l = fieldList(); - for(StringList::ConstIterator it = l.begin(); it != l.end(); ++it) { + for (StringList::ConstIterator it = l.begin(); it != l.end(); ++it) { String instrument = it->upper(); - if(instrument.isEmpty()) { + if (instrument.isEmpty()) { // instrument is not a valid key -> frame unsupported map.clear(); map.unsupportedData().append(frameID()); @@ -312,10 +293,8 @@ PropertyMap TextIdentificationFrame::makeTMCLProperties() const // UserTextIdentificationFrame public members //////////////////////////////////////////////////////////////////////////////// -UserTextIdentificationFrame::UserTextIdentificationFrame(String::Type encoding) : - TextIdentificationFrame("TXXX", encoding), - d(0) -{ +UserTextIdentificationFrame::UserTextIdentificationFrame(String::Type encoding) : TextIdentificationFrame("TXXX", encoding), + d(0) { StringList l; l.append(String()); l.append(String()); @@ -323,66 +302,54 @@ UserTextIdentificationFrame::UserTextIdentificationFrame(String::Type encoding) } -UserTextIdentificationFrame::UserTextIdentificationFrame(const ByteVector &data) : - TextIdentificationFrame(data) -{ +UserTextIdentificationFrame::UserTextIdentificationFrame(const ByteVector &data) : TextIdentificationFrame(data) { checkFields(); } -UserTextIdentificationFrame::UserTextIdentificationFrame(const String &description, const StringList &values, String::Type encoding) : - TextIdentificationFrame("TXXX", encoding), - d(0) -{ +UserTextIdentificationFrame::UserTextIdentificationFrame(const String &description, const StringList &values, String::Type encoding) : TextIdentificationFrame("TXXX", encoding), + d(0) { setDescription(description); setText(values); } -String UserTextIdentificationFrame::toString() const -{ +String UserTextIdentificationFrame::toString() const { // first entry is the description itself, drop from values list StringList l = fieldList(); - for(StringList::Iterator it = l.begin(); it != l.end(); ++it) { + for (StringList::Iterator it = l.begin(); it != l.end(); ++it) { l.erase(it); break; } return "[" + description() + "] " + l.toString(); } -String UserTextIdentificationFrame::description() const -{ - return !TextIdentificationFrame::fieldList().isEmpty() - ? TextIdentificationFrame::fieldList().front() - : String(); +String UserTextIdentificationFrame::description() const { + return !TextIdentificationFrame::fieldList().isEmpty() ? TextIdentificationFrame::fieldList().front() : String(); } -StringList UserTextIdentificationFrame::fieldList() const -{ +StringList UserTextIdentificationFrame::fieldList() const { // TODO: remove this function return TextIdentificationFrame::fieldList(); } -void UserTextIdentificationFrame::setText(const String &text) -{ - if(description().isEmpty()) +void UserTextIdentificationFrame::setText(const String &text) { + if (description().isEmpty()) setDescription(String()); TextIdentificationFrame::setText(StringList(description()).append(text)); } -void UserTextIdentificationFrame::setText(const StringList &fields) -{ - if(description().isEmpty()) +void UserTextIdentificationFrame::setText(const StringList &fields) { + if (description().isEmpty()) setDescription(String()); TextIdentificationFrame::setText(StringList(description()).append(fields)); } -void UserTextIdentificationFrame::setDescription(const String &s) -{ +void UserTextIdentificationFrame::setDescription(const String &s) { StringList l = fieldList(); - if(l.isEmpty()) + if (l.isEmpty()) l.append(s); else l[0] = s; @@ -390,24 +357,23 @@ void UserTextIdentificationFrame::setDescription(const String &s) TextIdentificationFrame::setText(l); } -PropertyMap UserTextIdentificationFrame::asProperties() const -{ +PropertyMap UserTextIdentificationFrame::asProperties() const { PropertyMap map; String tagName = txxxToKey(description()); StringList v = fieldList(); - for(StringList::ConstIterator it = v.begin(); it != v.end(); ++it) - if(it != v.begin()) + for (StringList::ConstIterator it = v.begin(); it != v.end(); ++it) + if (it != v.begin()) map.insert(tagName, *it); return map; } UserTextIdentificationFrame *UserTextIdentificationFrame::find( - ID3v2::Tag *tag, const String &description) // static + ID3v2::Tag *tag, const String &description) // static { FrameList l = tag->frameList("TXXX"); - for(FrameList::ConstIterator it = l.begin(); it != l.end(); ++it) { + for (FrameList::ConstIterator it = l.begin(); it != l.end(); ++it) { UserTextIdentificationFrame *f = dynamic_cast(*it); - if(f && f->description() == description) + if (f && f->description() == description) return f; } return nullptr; @@ -417,18 +383,15 @@ UserTextIdentificationFrame *UserTextIdentificationFrame::find( // UserTextIdentificationFrame private members //////////////////////////////////////////////////////////////////////////////// -UserTextIdentificationFrame::UserTextIdentificationFrame(const ByteVector &data, Header *h) : - TextIdentificationFrame(data, h) -{ +UserTextIdentificationFrame::UserTextIdentificationFrame(const ByteVector &data, Header *h) : TextIdentificationFrame(data, h) { checkFields(); } -void UserTextIdentificationFrame::checkFields() -{ +void UserTextIdentificationFrame::checkFields() { int fields = fieldList().size(); - if(fields == 0) + if (fields == 0) setDescription(String()); - if(fields <= 1) + if (fields <= 1) setText(String()); } diff --git a/3rdparty/taglib/mpeg/id3v2/frames/textidentificationframe.h b/3rdparty/taglib/mpeg/id3v2/frames/textidentificationframe.h index bd1a8d6db..1670629df 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/textidentificationframe.h +++ b/3rdparty/taglib/mpeg/id3v2/frames/textidentificationframe.h @@ -35,14 +35,14 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace ID3v2 { +namespace ID3v2 { - class Tag; - typedef Map KeyConversionMap; +class Tag; +typedef Map KeyConversionMap; - //! An ID3v2 text identification frame implementation +//! An ID3v2 text identification frame implementation - /*! +/*! * This is an implementation of the most common type of ID3v2 frame -- text * identification frames. There are a number of variations on this. Those * enumerated in the ID3v2.4 standard are: @@ -104,12 +104,11 @@ namespace TagLib { * (with the encoding flag appropriately set in the output). */ - class TAGLIB_EXPORT TextIdentificationFrame : public Frame - { - friend class FrameFactory; +class TAGLIB_EXPORT TextIdentificationFrame : public Frame { + friend class FrameFactory; - public: - /*! + public: + /*! * Construct an empty frame of type \a type. Uses \a encoding as the * default text encoding. * @@ -118,34 +117,34 @@ namespace TagLib { * * \note Please see the note in the class description regarding Latin1. */ - TextIdentificationFrame(const ByteVector &type, String::Type encoding); + TextIdentificationFrame(const ByteVector &type, String::Type encoding); - /*! + /*! * This is a dual purpose constructor. \a data can either be binary data * that should be parsed or (at a minimum) the frame ID. */ - explicit TextIdentificationFrame(const ByteVector &data); + explicit TextIdentificationFrame(const ByteVector &data); - /*! + /*! * This is a special factory method to create a TIPL (involved people list) * frame from the given \a properties. Will parse key=[list of values] data * into the TIPL format as specified in the ID3 standard. */ - static TextIdentificationFrame *createTIPLFrame(const PropertyMap &properties); + static TextIdentificationFrame *createTIPLFrame(const PropertyMap &properties); - /*! + /*! * This is a special factory method to create a TMCL (musician credits list) * frame from the given \a properties. Will parse key=[list of values] data * into the TMCL format as specified in the ID3 standard, where key should be * of the form instrumentPrefix:instrument. */ - static TextIdentificationFrame *createTMCLFrame(const PropertyMap &properties); - /*! + static TextIdentificationFrame *createTMCLFrame(const PropertyMap &properties); + /*! * Destroys this TextIdentificationFrame instance. */ - virtual ~TextIdentificationFrame(); + virtual ~TextIdentificationFrame(); - /*! + /*! * Text identification frames are a list of string fields. * * This function will accept either a StringList or a String (using the @@ -155,14 +154,14 @@ namespace TagLib { * strings passed in are not of the same encoding. Please use * setEncoding(s.type()) if you wish to change the encoding of the frame. */ - void setText(const StringList &l); + void setText(const StringList &l); - // Reimplementations. + // Reimplementations. - virtual void setText(const String &s); - virtual String toString() const; + virtual void setText(const String &s); + virtual String toString() const; - /*! + /*! * Returns the text encoding that will be used in rendering this frame. * This defaults to the type that was either specified in the constructor * or read from the frame when parsed. @@ -172,9 +171,9 @@ namespace TagLib { * \see setTextEncoding() * \see render() */ - String::Type textEncoding() const; + String::Type textEncoding() const; - /*! + /*! * Sets the text encoding to be used when rendering this frame to * \a encoding. * @@ -183,51 +182,51 @@ namespace TagLib { * \see textEncoding() * \see render() */ - void setTextEncoding(String::Type encoding); + void setTextEncoding(String::Type encoding); - /*! + /*! * Returns a list of the strings in this frame. */ - StringList fieldList() const; + StringList fieldList() const; - /*! + /*! * Returns a KeyConversionMap mapping a role as it would be used in a PropertyMap * to the corresponding key used in a TIPL ID3 frame to describe that role. */ - static const KeyConversionMap &involvedPeopleMap(); + static const KeyConversionMap &involvedPeopleMap(); - PropertyMap asProperties() const; + PropertyMap asProperties() const; - protected: - // Reimplementations. + protected: + // Reimplementations. - virtual void parseFields(const ByteVector &data); - virtual ByteVector renderFields() const; + virtual void parseFields(const ByteVector &data); + virtual ByteVector renderFields() const; - /*! + /*! * The constructor used by the FrameFactory. */ - TextIdentificationFrame(const ByteVector &data, Header *h); + TextIdentificationFrame(const ByteVector &data, Header *h); - private: - TextIdentificationFrame(const TextIdentificationFrame &); - TextIdentificationFrame &operator=(const TextIdentificationFrame &); + private: + TextIdentificationFrame(const TextIdentificationFrame &); + TextIdentificationFrame &operator=(const TextIdentificationFrame &); - /*! + /*! * Parses the special structure of a TIPL frame * Only the whitelisted roles "ARRANGER", "ENGINEER", "PRODUCER", * "DJMIXER" (ID3: "DJ-MIX") and "MIXER" (ID3: "MIX") are allowed. */ - PropertyMap makeTIPLProperties() const; - /*! + PropertyMap makeTIPLProperties() const; + /*! * Parses the special structure of a TMCL frame. */ - PropertyMap makeTMCLProperties() const; - class TextIdentificationFramePrivate; - TextIdentificationFramePrivate *d; - }; + PropertyMap makeTMCLProperties() const; + class TextIdentificationFramePrivate; + TextIdentificationFramePrivate *d; +}; - /*! +/*! * This is a specialization of text identification frames that allows for * user defined entries. Each entry has a description in addition to the * normal list of fields that a text identification frame has. @@ -235,49 +234,48 @@ namespace TagLib { * This description identifies the frame and must be unique. */ - //! An ID3v2 custom text identification frame implementation +//! An ID3v2 custom text identification frame implementation - class TAGLIB_EXPORT UserTextIdentificationFrame : public TextIdentificationFrame - { - friend class FrameFactory; +class TAGLIB_EXPORT UserTextIdentificationFrame : public TextIdentificationFrame { + friend class FrameFactory; - public: - /*! + public: + /*! * Constructs an empty user defined text identification frame. For this to be * a useful frame both a description and text must be set. */ - explicit UserTextIdentificationFrame(String::Type encoding = String::Latin1); + explicit UserTextIdentificationFrame(String::Type encoding = String::Latin1); - /*! + /*! * Creates a frame based on \a data. */ - explicit UserTextIdentificationFrame(const ByteVector &data); + explicit UserTextIdentificationFrame(const ByteVector &data); - /*! + /*! * Creates a user defined text identification frame with the given \a description * and \a values. */ - UserTextIdentificationFrame(const String &description, const StringList &values, String::Type encoding = String::UTF8); + UserTextIdentificationFrame(const String &description, const StringList &values, String::Type encoding = String::UTF8); - virtual String toString() const; + virtual String toString() const; - /*! + /*! * Returns the description for this frame. */ - String description() const; + String description() const; - /*! + /*! * Sets the description of the frame to \a s. \a s must be unique. You can * check for the presence of another user defined text frame of the same type * using find() and testing for null. */ - void setDescription(const String &s); + void setDescription(const String &s); - StringList fieldList() const; - void setText(const String &text); - void setText(const StringList &fields); + StringList fieldList() const; + void setText(const String &text); + void setText(const StringList &fields); - /*! + /*! * A UserTextIdentificationFrame is parsed into a PropertyMap as follows: * - the key is the frame's description, uppercased * - if the description contains '::', only the substring after that @@ -290,26 +288,26 @@ namespace TagLib { * in the value list, in order to be compatible with TagLib which copies * the description() into the fieldList(). */ - PropertyMap asProperties() const; + PropertyMap asProperties() const; - /*! + /*! * Searches for the user defined text frame with the description \a description * in \a tag. This returns null if no matching frames were found. */ - static UserTextIdentificationFrame *find(Tag *tag, const String &description); + static UserTextIdentificationFrame *find(Tag *tag, const String &description); - private: - UserTextIdentificationFrame(const ByteVector &data, Header *h); - UserTextIdentificationFrame(const TextIdentificationFrame &); - UserTextIdentificationFrame &operator=(const UserTextIdentificationFrame &); + private: + UserTextIdentificationFrame(const ByteVector &data, Header *h); + UserTextIdentificationFrame(const TextIdentificationFrame &); + UserTextIdentificationFrame &operator=(const UserTextIdentificationFrame &); - void checkFields(); + void checkFields(); - class UserTextIdentificationFramePrivate; - UserTextIdentificationFramePrivate *d; - }; + class UserTextIdentificationFramePrivate; + UserTextIdentificationFramePrivate *d; +}; - } -} -} +} // namespace ID3v2 +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/id3v2/frames/uniquefileidentifierframe.cpp b/3rdparty/taglib/mpeg/id3v2/frames/uniquefileidentifierframe.cpp index 8a4140564..18d8acf94 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/uniquefileidentifierframe.cpp +++ b/3rdparty/taglib/mpeg/id3v2/frames/uniquefileidentifierframe.cpp @@ -33,9 +33,8 @@ using namespace Strawberry_TagLib::TagLib; using namespace ID3v2; -class UniqueFileIdentifierFrame::UniqueFileIdentifierFramePrivate -{ -public: +class UniqueFileIdentifierFrame::UniqueFileIdentifierFramePrivate { + public: String owner; ByteVector identifier; }; @@ -44,55 +43,44 @@ public: // public methods //////////////////////////////////////////////////////////////////////////////// -UniqueFileIdentifierFrame::UniqueFileIdentifierFrame(const ByteVector &data) : - ID3v2::Frame(data), - d(new UniqueFileIdentifierFramePrivate()) -{ +UniqueFileIdentifierFrame::UniqueFileIdentifierFrame(const ByteVector &data) : ID3v2::Frame(data), + d(new UniqueFileIdentifierFramePrivate()) { setData(data); } -UniqueFileIdentifierFrame::UniqueFileIdentifierFrame(const String &owner, const ByteVector &id) : - ID3v2::Frame("UFID"), - d(new UniqueFileIdentifierFramePrivate()) -{ +UniqueFileIdentifierFrame::UniqueFileIdentifierFrame(const String &owner, const ByteVector &id) : ID3v2::Frame("UFID"), + d(new UniqueFileIdentifierFramePrivate()) { d->owner = owner; d->identifier = id; } -UniqueFileIdentifierFrame::~UniqueFileIdentifierFrame() -{ +UniqueFileIdentifierFrame::~UniqueFileIdentifierFrame() { delete d; } -String UniqueFileIdentifierFrame::owner() const -{ - return d->owner; +String UniqueFileIdentifierFrame::owner() const { + return d->owner; } -ByteVector UniqueFileIdentifierFrame::identifier() const -{ +ByteVector UniqueFileIdentifierFrame::identifier() const { return d->identifier; } -void UniqueFileIdentifierFrame::setOwner(const String &s) -{ +void UniqueFileIdentifierFrame::setOwner(const String &s) { d->owner = s; } -void UniqueFileIdentifierFrame::setIdentifier(const ByteVector &v) -{ +void UniqueFileIdentifierFrame::setIdentifier(const ByteVector &v) { d->identifier = v; } -String UniqueFileIdentifierFrame::toString() const -{ +String UniqueFileIdentifierFrame::toString() const { return String(); } -PropertyMap UniqueFileIdentifierFrame::asProperties() const -{ +PropertyMap UniqueFileIdentifierFrame::asProperties() const { PropertyMap map; - if(d->owner == "http://musicbrainz.org") { + if (d->owner == "http://musicbrainz.org") { map.insert("MUSICBRAINZ_TRACKID", String(d->identifier)); } else { @@ -101,25 +89,23 @@ PropertyMap UniqueFileIdentifierFrame::asProperties() const return map; } -UniqueFileIdentifierFrame *UniqueFileIdentifierFrame::findByOwner(const ID3v2::Tag *tag, const String &o) // static +UniqueFileIdentifierFrame *UniqueFileIdentifierFrame::findByOwner(const ID3v2::Tag *tag, const String &o) // static { ID3v2::FrameList comments = tag->frameList("UFID"); - for(ID3v2::FrameList::ConstIterator it = comments.begin(); - it != comments.end(); - ++it) - { + for (ID3v2::FrameList::ConstIterator it = comments.begin(); + it != comments.end(); + ++it) { UniqueFileIdentifierFrame *frame = dynamic_cast(*it); - if(frame && frame->owner() == o) + if (frame && frame->owner() == o) return frame; } return nullptr; } -void UniqueFileIdentifierFrame::parseFields(const ByteVector &data) -{ - if(data.size() < 1) { +void UniqueFileIdentifierFrame::parseFields(const ByteVector &data) { + if (data.size() < 1) { debug("An UFID frame must contain at least 1 byte."); return; } @@ -129,8 +115,7 @@ void UniqueFileIdentifierFrame::parseFields(const ByteVector &data) d->identifier = data.mid(pos); } -ByteVector UniqueFileIdentifierFrame::renderFields() const -{ +ByteVector UniqueFileIdentifierFrame::renderFields() const { ByteVector data; data.append(d->owner.data(String::Latin1)); @@ -140,9 +125,7 @@ ByteVector UniqueFileIdentifierFrame::renderFields() const return data; } -UniqueFileIdentifierFrame::UniqueFileIdentifierFrame(const ByteVector &data, Header *h) : - Frame(h), - d(new UniqueFileIdentifierFramePrivate()) -{ +UniqueFileIdentifierFrame::UniqueFileIdentifierFrame(const ByteVector &data, Header *h) : Frame(h), + d(new UniqueFileIdentifierFramePrivate()) { parseFields(fieldData(data)); } diff --git a/3rdparty/taglib/mpeg/id3v2/frames/uniquefileidentifierframe.h b/3rdparty/taglib/mpeg/id3v2/frames/uniquefileidentifierframe.h index 5e06872ff..5b37347ed 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/uniquefileidentifierframe.h +++ b/3rdparty/taglib/mpeg/id3v2/frames/uniquefileidentifierframe.h @@ -31,38 +31,37 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace ID3v2 { +namespace ID3v2 { - /*! +/*! * This is an implementation of ID3v2 unique file identifier frames. This * frame is used to identify the file in an arbitrary database identified * by the owner field. */ - //! An implementation of ID3v2 unique identifier frames +//! An implementation of ID3v2 unique identifier frames - class TAGLIB_EXPORT UniqueFileIdentifierFrame : public ID3v2::Frame - { - friend class FrameFactory; +class TAGLIB_EXPORT UniqueFileIdentifierFrame : public ID3v2::Frame { + friend class FrameFactory; - public: - /*! + public: + /*! * Creates a unique file identifier frame based on \a data. */ - UniqueFileIdentifierFrame(const ByteVector &data); + UniqueFileIdentifierFrame(const ByteVector &data); - /*! + /*! * Creates a unique file identifier frame with the owner \a owner and * the identification \a id. */ - UniqueFileIdentifierFrame(const String &owner, const ByteVector &id); + UniqueFileIdentifierFrame(const String &owner, const ByteVector &id); - /*! + /*! * Destroys the frame. */ - ~UniqueFileIdentifierFrame(); + ~UniqueFileIdentifierFrame(); - /*! + /*! * Returns the owner for the frame; essentially this is the key for * determining which identification scheme this key belongs to. This * will usually either be an email address or URL for the person or tool @@ -70,56 +69,56 @@ namespace TagLib { * * \see setOwner() */ - String owner() const; + String owner() const; - /*! + /*! * Returns the unique identifier. Though sometimes this is a text string * it also may be binary data and as much should be assumed when handling * it. */ - ByteVector identifier() const; + ByteVector identifier() const; - /*! + /*! * Sets the owner of the identification scheme to \a s. * * \see owner() */ - void setOwner(const String &s); + void setOwner(const String &s); - /*! + /*! * Sets the unique file identifier to \a v. * * \see identifier() */ - void setIdentifier(const ByteVector &v); + void setIdentifier(const ByteVector &v); - virtual String toString() const; + virtual String toString() const; - PropertyMap asProperties() const; + PropertyMap asProperties() const; - /*! + /*! * UFID frames each have a unique owner. This searches for a UFID * frame with the owner \a o and returns a pointer to it. * * \see owner() */ - static UniqueFileIdentifierFrame *findByOwner(const Tag *tag, const String &o); + static UniqueFileIdentifierFrame *findByOwner(const Tag *tag, const String &o); - protected: - virtual void parseFields(const ByteVector &data); - virtual ByteVector renderFields() const; + protected: + virtual void parseFields(const ByteVector &data); + virtual ByteVector renderFields() const; - private: - UniqueFileIdentifierFrame(const UniqueFileIdentifierFrame &); - UniqueFileIdentifierFrame &operator=(const UniqueFileIdentifierFrame &); + private: + UniqueFileIdentifierFrame(const UniqueFileIdentifierFrame &); + UniqueFileIdentifierFrame &operator=(const UniqueFileIdentifierFrame &); - UniqueFileIdentifierFrame(const ByteVector &data, Header *h); + UniqueFileIdentifierFrame(const ByteVector &data, Header *h); - class UniqueFileIdentifierFramePrivate; - UniqueFileIdentifierFramePrivate *d; - }; - } -} -} + class UniqueFileIdentifierFramePrivate; + UniqueFileIdentifierFramePrivate *d; +}; +} // namespace ID3v2 +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/id3v2/frames/unknownframe.cpp b/3rdparty/taglib/mpeg/id3v2/frames/unknownframe.cpp index 57dfc3b58..c92b41fe7 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/unknownframe.cpp +++ b/3rdparty/taglib/mpeg/id3v2/frames/unknownframe.cpp @@ -28,9 +28,8 @@ using namespace Strawberry_TagLib::TagLib; using namespace ID3v2; -class UnknownFrame::UnknownFramePrivate -{ -public: +class UnknownFrame::UnknownFramePrivate { + public: ByteVector fieldData; }; @@ -38,25 +37,20 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -UnknownFrame::UnknownFrame(const ByteVector &data) : - Frame(data), - d(new UnknownFramePrivate()) -{ +UnknownFrame::UnknownFrame(const ByteVector &data) : Frame(data), + d(new UnknownFramePrivate()) { setData(data); } -UnknownFrame::~UnknownFrame() -{ +UnknownFrame::~UnknownFrame() { delete d; } -String UnknownFrame::toString() const -{ +String UnknownFrame::toString() const { return String(); } -ByteVector UnknownFrame::data() const -{ +ByteVector UnknownFrame::data() const { return d->fieldData; } @@ -64,13 +58,11 @@ ByteVector UnknownFrame::data() const // protected members //////////////////////////////////////////////////////////////////////////////// -void UnknownFrame::parseFields(const ByteVector &data) -{ +void UnknownFrame::parseFields(const ByteVector &data) { d->fieldData = data; } -ByteVector UnknownFrame::renderFields() const -{ +ByteVector UnknownFrame::renderFields() const { return d->fieldData; } @@ -78,9 +70,7 @@ ByteVector UnknownFrame::renderFields() const // private members //////////////////////////////////////////////////////////////////////////////// -UnknownFrame::UnknownFrame(const ByteVector &data, Header *h) : - Frame(h), - d(new UnknownFramePrivate()) -{ +UnknownFrame::UnknownFrame(const ByteVector &data, Header *h) : Frame(h), + d(new UnknownFramePrivate()) { parseFields(fieldData(data)); } diff --git a/3rdparty/taglib/mpeg/id3v2/frames/unknownframe.h b/3rdparty/taglib/mpeg/id3v2/frames/unknownframe.h index 48a35bceb..cf766e9f6 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/unknownframe.h +++ b/3rdparty/taglib/mpeg/id3v2/frames/unknownframe.h @@ -32,11 +32,11 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace ID3v2 { +namespace ID3v2 { - //! A frame type \e unknown to TagLib. +//! A frame type \e unknown to TagLib. - /*! +/*! * This class represents a frame type not known (or more often simply * unimplemented) in TagLib. This is here provide a basic API for * manipulating the binary data of unknown frames and to provide a means @@ -47,35 +47,34 @@ namespace TagLib { * to have your frame type supported through the standard ID3v2 mechanism. */ - class TAGLIB_EXPORT UnknownFrame : public Frame - { - friend class FrameFactory; +class TAGLIB_EXPORT UnknownFrame : public Frame { + friend class FrameFactory; - public: - UnknownFrame(const ByteVector &data); - virtual ~UnknownFrame(); + public: + UnknownFrame(const ByteVector &data); + virtual ~UnknownFrame(); - virtual String toString() const; + virtual String toString() const; - /*! + /*! * Returns the field data (everything but the header) for this frame. */ - ByteVector data() const; + ByteVector data() const; - protected: - virtual void parseFields(const ByteVector &data); - virtual ByteVector renderFields() const; + protected: + virtual void parseFields(const ByteVector &data); + virtual ByteVector renderFields() const; - private: - UnknownFrame(const ByteVector &data, Header *h); - UnknownFrame(const UnknownFrame &); - UnknownFrame &operator=(const UnknownFrame &); + private: + UnknownFrame(const ByteVector &data, Header *h); + UnknownFrame(const UnknownFrame &); + UnknownFrame &operator=(const UnknownFrame &); - class UnknownFramePrivate; - UnknownFramePrivate *d; - }; + class UnknownFramePrivate; + UnknownFramePrivate *d; +}; - } -} -} +} // namespace ID3v2 +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.cpp b/3rdparty/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.cpp index 0ec0bda05..c9d3cbea0 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.cpp +++ b/3rdparty/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.cpp @@ -35,9 +35,8 @@ using namespace Strawberry_TagLib::TagLib; using namespace ID3v2; -class UnsynchronizedLyricsFrame::UnsynchronizedLyricsFramePrivate -{ -public: +class UnsynchronizedLyricsFrame::UnsynchronizedLyricsFramePrivate { + public: UnsynchronizedLyricsFramePrivate() : textEncoding(String::Latin1) {} String::Type textEncoding; ByteVector language; @@ -49,89 +48,74 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -UnsynchronizedLyricsFrame::UnsynchronizedLyricsFrame(String::Type encoding) : - Frame("USLT"), - d(new UnsynchronizedLyricsFramePrivate()) -{ +UnsynchronizedLyricsFrame::UnsynchronizedLyricsFrame(String::Type encoding) : Frame("USLT"), + d(new UnsynchronizedLyricsFramePrivate()) { d->textEncoding = encoding; } -UnsynchronizedLyricsFrame::UnsynchronizedLyricsFrame(const ByteVector &data) : - Frame(data), - d(new UnsynchronizedLyricsFramePrivate()) -{ +UnsynchronizedLyricsFrame::UnsynchronizedLyricsFrame(const ByteVector &data) : Frame(data), + d(new UnsynchronizedLyricsFramePrivate()) { setData(data); } -UnsynchronizedLyricsFrame::~UnsynchronizedLyricsFrame() -{ +UnsynchronizedLyricsFrame::~UnsynchronizedLyricsFrame() { delete d; } -String UnsynchronizedLyricsFrame::toString() const -{ +String UnsynchronizedLyricsFrame::toString() const { return d->text; } -ByteVector UnsynchronizedLyricsFrame::language() const -{ +ByteVector UnsynchronizedLyricsFrame::language() const { return d->language; } -String UnsynchronizedLyricsFrame::description() const -{ +String UnsynchronizedLyricsFrame::description() const { return d->description; } -String UnsynchronizedLyricsFrame::text() const -{ +String UnsynchronizedLyricsFrame::text() const { return d->text; } -void UnsynchronizedLyricsFrame::setLanguage(const ByteVector &languageEncoding) -{ +void UnsynchronizedLyricsFrame::setLanguage(const ByteVector &languageEncoding) { d->language = languageEncoding.mid(0, 3); } -void UnsynchronizedLyricsFrame::setDescription(const String &s) -{ +void UnsynchronizedLyricsFrame::setDescription(const String &s) { d->description = s; } -void UnsynchronizedLyricsFrame::setText(const String &s) -{ +void UnsynchronizedLyricsFrame::setText(const String &s) { d->text = s; } -String::Type UnsynchronizedLyricsFrame::textEncoding() const -{ +String::Type UnsynchronizedLyricsFrame::textEncoding() const { return d->textEncoding; } -void UnsynchronizedLyricsFrame::setTextEncoding(String::Type encoding) -{ +void UnsynchronizedLyricsFrame::setTextEncoding(String::Type encoding) { d->textEncoding = encoding; } -PropertyMap UnsynchronizedLyricsFrame::asProperties() const -{ +PropertyMap UnsynchronizedLyricsFrame::asProperties() const { PropertyMap map; String key = description().upper(); - if(key.isEmpty() || key == "LYRICS") + if (key.isEmpty() || key == "LYRICS") map.insert("LYRICS", text()); else map.insert("LYRICS:" + key, text()); return map; } -UnsynchronizedLyricsFrame *UnsynchronizedLyricsFrame::findByDescription(const ID3v2::Tag *tag, const String &d) // static +UnsynchronizedLyricsFrame *UnsynchronizedLyricsFrame::findByDescription(const ID3v2::Tag *tag, const String &d) // static { ID3v2::FrameList lyrics = tag->frameList("USLT"); - for(ID3v2::FrameList::ConstIterator it = lyrics.begin(); it != lyrics.end(); ++it){ + for (ID3v2::FrameList::ConstIterator it = lyrics.begin(); it != lyrics.end(); ++it) { UnsynchronizedLyricsFrame *frame = dynamic_cast(*it); - if(frame && frame->description() == d) + if (frame && frame->description() == d) return frame; } return nullptr; @@ -140,9 +124,8 @@ UnsynchronizedLyricsFrame *UnsynchronizedLyricsFrame::findByDescription(const ID // protected members //////////////////////////////////////////////////////////////////////////////// -void UnsynchronizedLyricsFrame::parseFields(const ByteVector &data) -{ - if(data.size() < 5) { +void UnsynchronizedLyricsFrame::parseFields(const ByteVector &data) { + if (data.size() < 5) { debug("An unsynchronized lyrics frame must contain at least 5 bytes."); return; } @@ -150,25 +133,24 @@ void UnsynchronizedLyricsFrame::parseFields(const ByteVector &data) d->textEncoding = String::Type(data[0]); d->language = data.mid(1, 3); - int byteAlign - = d->textEncoding == String::Latin1 || d->textEncoding == String::UTF8 ? 1 : 2; + int byteAlign = d->textEncoding == String::Latin1 || d->textEncoding == String::UTF8 ? 1 : 2; ByteVectorList l = ByteVectorList::split(data.mid(4), textDelimiter(d->textEncoding), byteAlign, 2); - if(l.size() == 2) { - if(d->textEncoding == String::Latin1) { + if (l.size() == 2) { + if (d->textEncoding == String::Latin1) { d->description = Tag::latin1StringHandler()->parse(l.front()); d->text = Tag::latin1StringHandler()->parse(l.back()); - } else { + } + else { d->description = String(l.front(), d->textEncoding); d->text = String(l.back(), d->textEncoding); } } } -ByteVector UnsynchronizedLyricsFrame::renderFields() const -{ +ByteVector UnsynchronizedLyricsFrame::renderFields() const { StringList sl; sl.append(d->description); sl.append(d->text); @@ -190,9 +172,7 @@ ByteVector UnsynchronizedLyricsFrame::renderFields() const // private members //////////////////////////////////////////////////////////////////////////////// -UnsynchronizedLyricsFrame::UnsynchronizedLyricsFrame(const ByteVector &data, Header *h) : - Frame(h), - d(new UnsynchronizedLyricsFramePrivate()) -{ +UnsynchronizedLyricsFrame::UnsynchronizedLyricsFrame(const ByteVector &data, Header *h) : Frame(h), + d(new UnsynchronizedLyricsFramePrivate()) { parseFields(fieldData(data)); } diff --git a/3rdparty/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.h b/3rdparty/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.h index c70afe7d7..e25d87332 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.h +++ b/3rdparty/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.h @@ -33,41 +33,40 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace ID3v2 { +namespace ID3v2 { - //! ID3v2 unsynchronized lyrics frame - /*! +//! ID3v2 unsynchronized lyrics frame +/*! * An implementation of ID3v2 unsynchronized lyrics. */ - class TAGLIB_EXPORT UnsynchronizedLyricsFrame : public Frame - { - friend class FrameFactory; +class TAGLIB_EXPORT UnsynchronizedLyricsFrame : public Frame { + friend class FrameFactory; - public: - /*! + public: + /*! * Construct an empty unsynchronized lyrics frame that will use the text encoding * \a encoding. */ - explicit UnsynchronizedLyricsFrame(String::Type encoding = String::Latin1); + explicit UnsynchronizedLyricsFrame(String::Type encoding = String::Latin1); - /*! + /*! * Construct a unsynchronized lyrics frame based on the data in \a data. */ - explicit UnsynchronizedLyricsFrame(const ByteVector &data); + explicit UnsynchronizedLyricsFrame(const ByteVector &data); - /*! + /*! * Destroys this UnsynchronizedLyricsFrame instance. */ - virtual ~UnsynchronizedLyricsFrame(); + virtual ~UnsynchronizedLyricsFrame(); - /*! + /*! * Returns the text of this unsynchronized lyrics frame. * * \see text() */ - virtual String toString() const; + virtual String toString() const; - /*! + /*! * Returns the language encoding as a 3 byte encoding as specified by * ISO-639-2. * @@ -75,48 +74,48 @@ namespace TagLib { * * \see setLanguage() */ - ByteVector language() const; + ByteVector language() const; - /*! + /*! * Returns the description of this unsynchronized lyrics frame. * * \note Most taggers simply ignore this value. * * \see setDescription() */ - String description() const; + String description() const; - /*! + /*! * Returns the text of this unsynchronized lyrics frame. * * \see setText() */ - String text() const; + String text() const; - /*! + /*! * Set the language using the 3 byte language code from * ISO-639-2 to * \a languageCode. * * \see language() */ - void setLanguage(const ByteVector &languageCode); + void setLanguage(const ByteVector &languageCode); - /*! + /*! * Sets the description of the unsynchronized lyrics frame to \a s. * * \see description() */ - void setDescription(const String &s); + void setDescription(const String &s); - /*! + /*! * Sets the text portion of the unsynchronized lyrics frame to \a s. * * \see text() */ - virtual void setText(const String &s); + virtual void setText(const String &s); - /*! + /*! * Returns the text encoding that will be used in rendering this frame. * This defaults to the type that was either specified in the constructor * or read from the frame when parsed. @@ -124,19 +123,19 @@ namespace TagLib { * \see setTextEncoding() * \see render() */ - String::Type textEncoding() const; + String::Type textEncoding() const; - /*! + /*! * Sets the text encoding to be used when rendering this frame to * \a encoding. * * \see textEncoding() * \see render() */ - void setTextEncoding(String::Type encoding); + void setTextEncoding(String::Type encoding); - /*! Parses this frame as PropertyMap with a single key. + /*! Parses this frame as PropertyMap with a single key. * - if description() is empty or "LYRICS", the key will be "LYRICS" * - if description() is not a valid PropertyMap key, the frame will be * marked unsupported by an entry "USLT/" in the unsupportedData() @@ -146,36 +145,36 @@ namespace TagLib { * Note that currently the language() field is not supported by the PropertyMap * interface. */ - PropertyMap asProperties() const; + PropertyMap asProperties() const; - /*! + /*! * LyricsFrames each have a unique description. This searches for a lyrics * frame with the description \a d and returns a pointer to it. If no * frame is found that matches the given description null is returned. * * \see description() */ - static UnsynchronizedLyricsFrame *findByDescription(const Tag *tag, const String &d); + static UnsynchronizedLyricsFrame *findByDescription(const Tag *tag, const String &d); - protected: - // Reimplementations. + protected: + // Reimplementations. - virtual void parseFields(const ByteVector &data); - virtual ByteVector renderFields() const; + virtual void parseFields(const ByteVector &data); + virtual ByteVector renderFields() const; - private: - /*! + private: + /*! * The constructor used by the FrameFactory. */ - UnsynchronizedLyricsFrame(const ByteVector &data, Header *h); - UnsynchronizedLyricsFrame(const UnsynchronizedLyricsFrame &); - UnsynchronizedLyricsFrame &operator=(const UnsynchronizedLyricsFrame &); + UnsynchronizedLyricsFrame(const ByteVector &data, Header *h); + UnsynchronizedLyricsFrame(const UnsynchronizedLyricsFrame &); + UnsynchronizedLyricsFrame &operator=(const UnsynchronizedLyricsFrame &); - class UnsynchronizedLyricsFramePrivate; - UnsynchronizedLyricsFramePrivate *d; - }; + class UnsynchronizedLyricsFramePrivate; + UnsynchronizedLyricsFramePrivate *d; +}; - } -} -} +} // namespace ID3v2 +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/id3v2/frames/urllinkframe.cpp b/3rdparty/taglib/mpeg/id3v2/frames/urllinkframe.cpp index 7ecb77b23..18ad80303 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/urllinkframe.cpp +++ b/3rdparty/taglib/mpeg/id3v2/frames/urllinkframe.cpp @@ -35,15 +35,13 @@ using namespace Strawberry_TagLib::TagLib; using namespace ID3v2; -class UrlLinkFrame::UrlLinkFramePrivate -{ -public: +class UrlLinkFrame::UrlLinkFramePrivate { + public: String url; }; -class UserUrlLinkFrame::UserUrlLinkFramePrivate -{ -public: +class UserUrlLinkFrame::UserUrlLinkFramePrivate { + public: UserUrlLinkFramePrivate() : textEncoding(String::Latin1) {} String::Type textEncoding; String description; @@ -53,43 +51,35 @@ public: // UrlLinkFrame public members //////////////////////////////////////////////////////////////////////////////// -UrlLinkFrame::UrlLinkFrame(const ByteVector &data) : - Frame(data), - d(new UrlLinkFramePrivate()) -{ +UrlLinkFrame::UrlLinkFrame(const ByteVector &data) : Frame(data), + d(new UrlLinkFramePrivate()) { setData(data); } -UrlLinkFrame::~UrlLinkFrame() -{ +UrlLinkFrame::~UrlLinkFrame() { delete d; } -void UrlLinkFrame::setUrl(const String &s) -{ +void UrlLinkFrame::setUrl(const String &s) { d->url = s; } -String UrlLinkFrame::url() const -{ +String UrlLinkFrame::url() const { return d->url; } -void UrlLinkFrame::setText(const String &s) -{ +void UrlLinkFrame::setText(const String &s) { setUrl(s); } -String UrlLinkFrame::toString() const -{ +String UrlLinkFrame::toString() const { return url(); } -PropertyMap UrlLinkFrame::asProperties() const -{ +PropertyMap UrlLinkFrame::asProperties() const { String key = frameIDToKey(frameID()); PropertyMap map; - if(key.isEmpty()) + if (key.isEmpty()) // unknown W*** frame - this normally shouldn't happen map.unsupportedData().append(frameID()); else @@ -101,20 +91,16 @@ PropertyMap UrlLinkFrame::asProperties() const // UrlLinkFrame protected members //////////////////////////////////////////////////////////////////////////////// -void UrlLinkFrame::parseFields(const ByteVector &data) -{ +void UrlLinkFrame::parseFields(const ByteVector &data) { d->url = String(data); } -ByteVector UrlLinkFrame::renderFields() const -{ +ByteVector UrlLinkFrame::renderFields() const { return d->url.data(String::Latin1); } -UrlLinkFrame::UrlLinkFrame(const ByteVector &data, Header *h) : - Frame(h), - d(new UrlLinkFramePrivate()) -{ +UrlLinkFrame::UrlLinkFrame(const ByteVector &data, Header *h) : Frame(h), + d(new UrlLinkFramePrivate()) { parseFields(fieldData(data)); } @@ -122,67 +108,56 @@ UrlLinkFrame::UrlLinkFrame(const ByteVector &data, Header *h) : // UserUrlLinkFrame public members //////////////////////////////////////////////////////////////////////////////// -UserUrlLinkFrame::UserUrlLinkFrame(String::Type encoding) : - UrlLinkFrame("WXXX"), - d(new UserUrlLinkFramePrivate()) -{ +UserUrlLinkFrame::UserUrlLinkFrame(String::Type encoding) : UrlLinkFrame("WXXX"), + d(new UserUrlLinkFramePrivate()) { d->textEncoding = encoding; } -UserUrlLinkFrame::UserUrlLinkFrame(const ByteVector &data) : - UrlLinkFrame(data), - d(new UserUrlLinkFramePrivate()) -{ +UserUrlLinkFrame::UserUrlLinkFrame(const ByteVector &data) : UrlLinkFrame(data), + d(new UserUrlLinkFramePrivate()) { setData(data); } -UserUrlLinkFrame::~UserUrlLinkFrame() -{ +UserUrlLinkFrame::~UserUrlLinkFrame() { delete d; } -String UserUrlLinkFrame::toString() const -{ +String UserUrlLinkFrame::toString() const { return "[" + description() + "] " + url(); } -String::Type UserUrlLinkFrame::textEncoding() const -{ +String::Type UserUrlLinkFrame::textEncoding() const { return d->textEncoding; } -void UserUrlLinkFrame::setTextEncoding(String::Type encoding) -{ +void UserUrlLinkFrame::setTextEncoding(String::Type encoding) { d->textEncoding = encoding; } -String UserUrlLinkFrame::description() const -{ +String UserUrlLinkFrame::description() const { return d->description; } -void UserUrlLinkFrame::setDescription(const String &s) -{ +void UserUrlLinkFrame::setDescription(const String &s) { d->description = s; } -PropertyMap UserUrlLinkFrame::asProperties() const -{ +PropertyMap UserUrlLinkFrame::asProperties() const { PropertyMap map; String key = description().upper(); - if(key.isEmpty() || key == "URL") + if (key.isEmpty() || key == "URL") map.insert("URL", url()); else map.insert("URL:" + key, url()); return map; } -UserUrlLinkFrame *UserUrlLinkFrame::find(ID3v2::Tag *tag, const String &description) // static +UserUrlLinkFrame *UserUrlLinkFrame::find(ID3v2::Tag *tag, const String &description) // static { FrameList l = tag->frameList("WXXX"); - for(FrameList::ConstIterator it = l.begin(); it != l.end(); ++it) { + for (FrameList::ConstIterator it = l.begin(); it != l.end(); ++it) { UserUrlLinkFrame *f = dynamic_cast(*it); - if(f && f->description() == description) + if (f && f->description() == description) return f; } return nullptr; @@ -192,9 +167,8 @@ UserUrlLinkFrame *UserUrlLinkFrame::find(ID3v2::Tag *tag, const String &descript // UserUrlLinkFrame protected members //////////////////////////////////////////////////////////////////////////////// -void UserUrlLinkFrame::parseFields(const ByteVector &data) -{ - if(data.size() < 2) { +void UserUrlLinkFrame::parseFields(const ByteVector &data) { + if (data.size() < 2) { debug("A user URL link frame must contain at least 2 bytes."); return; } @@ -204,9 +178,9 @@ void UserUrlLinkFrame::parseFields(const ByteVector &data) d->textEncoding = String::Type(data[0]); pos += 1; - if(d->textEncoding == String::Latin1 || d->textEncoding == String::UTF8) { + if (d->textEncoding == String::Latin1 || d->textEncoding == String::UTF8) { int offset = data.find(textDelimiter(d->textEncoding), pos); - if(offset < pos) + if (offset < pos) return; d->description = String(data.mid(pos, offset - pos), d->textEncoding); @@ -214,7 +188,7 @@ void UserUrlLinkFrame::parseFields(const ByteVector &data) } else { int len = data.mid(pos).find(textDelimiter(d->textEncoding), 0, 2); - if(len < 0) + if (len < 0) return; d->description = String(data.mid(pos, len), d->textEncoding); @@ -224,8 +198,7 @@ void UserUrlLinkFrame::parseFields(const ByteVector &data) setUrl(String(data.mid(pos))); } -ByteVector UserUrlLinkFrame::renderFields() const -{ +ByteVector UserUrlLinkFrame::renderFields() const { ByteVector v; String::Type encoding = checkTextEncoding(d->description, d->textEncoding); @@ -238,9 +211,7 @@ ByteVector UserUrlLinkFrame::renderFields() const return v; } -UserUrlLinkFrame::UserUrlLinkFrame(const ByteVector &data, Header *h) : - UrlLinkFrame(data, h), - d(new UserUrlLinkFramePrivate()) -{ +UserUrlLinkFrame::UserUrlLinkFrame(const ByteVector &data, Header *h) : UrlLinkFrame(data, h), + d(new UserUrlLinkFramePrivate()) { parseFields(fieldData(data)); } diff --git a/3rdparty/taglib/mpeg/id3v2/frames/urllinkframe.h b/3rdparty/taglib/mpeg/id3v2/frames/urllinkframe.h index fba1b9d56..ffac9799d 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/urllinkframe.h +++ b/3rdparty/taglib/mpeg/id3v2/frames/urllinkframe.h @@ -34,97 +34,95 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace ID3v2 { +namespace ID3v2 { - //! ID3v2 URL frame - /*! +//! ID3v2 URL frame +/*! * An implementation of ID3v2 URL link frames. */ - class TAGLIB_EXPORT UrlLinkFrame : public Frame - { - friend class FrameFactory; +class TAGLIB_EXPORT UrlLinkFrame : public Frame { + friend class FrameFactory; - public: - /*! + public: + /*! * This is a dual purpose constructor. \a data can either be binary data * that should be parsed or (at a minimum) the frame ID. */ - explicit UrlLinkFrame(const ByteVector &data); + explicit UrlLinkFrame(const ByteVector &data); - /*! + /*! * Destroys this UrlLinkFrame instance. */ - virtual ~UrlLinkFrame(); + virtual ~UrlLinkFrame(); - /*! + /*! * Returns the URL. */ - virtual String url() const; + virtual String url() const; - /*! + /*! * Sets the URL to \a s. */ - virtual void setUrl(const String &s); + virtual void setUrl(const String &s); - // Reimplementations. + // Reimplementations. - virtual void setText(const String &s); - virtual String toString() const; - PropertyMap asProperties() const; + virtual void setText(const String &s); + virtual String toString() const; + PropertyMap asProperties() const; - protected: - virtual void parseFields(const ByteVector &data); - virtual ByteVector renderFields() const; + protected: + virtual void parseFields(const ByteVector &data); + virtual ByteVector renderFields() const; - /*! + /*! * The constructor used by the FrameFactory. */ - UrlLinkFrame(const ByteVector &data, Header *h); + UrlLinkFrame(const ByteVector &data, Header *h); - private: - UrlLinkFrame(const UrlLinkFrame &); - UrlLinkFrame &operator=(const UrlLinkFrame &); + private: + UrlLinkFrame(const UrlLinkFrame &); + UrlLinkFrame &operator=(const UrlLinkFrame &); - class UrlLinkFramePrivate; - UrlLinkFramePrivate *d; - }; + class UrlLinkFramePrivate; + UrlLinkFramePrivate *d; +}; - //! ID3v2 User defined URL frame +//! ID3v2 User defined URL frame - /*! +/*! * This is a specialization of URL link frames that allows for * user defined entries. Each entry has a description in addition to the * normal list of fields that a URL link frame has. * * This description identifies the frame and must be unique. */ - class TAGLIB_EXPORT UserUrlLinkFrame : public UrlLinkFrame - { - friend class FrameFactory; +class TAGLIB_EXPORT UserUrlLinkFrame : public UrlLinkFrame { + friend class FrameFactory; - public: - /*! + public: + /*! * Constructs an empty user defined URL link frame. For this to be * a useful frame both a description and text must be set. */ - explicit UserUrlLinkFrame(String::Type encoding = String::Latin1); + explicit UserUrlLinkFrame(String::Type encoding = String::Latin1); - /*! + /*! * This is a dual purpose constructor. \a data can either be binary data * that should be parsed or (at a minimum) the frame ID. */ - explicit UserUrlLinkFrame(const ByteVector &data); + explicit UserUrlLinkFrame(const ByteVector &data); - /*! + /*! * Destroys this UserUrlLinkFrame instance. */ - virtual ~UserUrlLinkFrame(); + virtual ~UserUrlLinkFrame(); - // Reimplementations. + // Reimplementations. - virtual String toString() const; + virtual String toString() const; - /*! + /*! * Returns the text encoding that will be used in rendering this frame. * This defaults to the type that was either specified in the constructor * or read from the frame when parsed. @@ -132,28 +130,28 @@ namespace TagLib { * \see setTextEncoding() * \see render() */ - String::Type textEncoding() const; + String::Type textEncoding() const; - /*! + /*! * Sets the text encoding to be used when rendering this frame to * \a encoding. * * \see textEncoding() * \see render() */ - void setTextEncoding(String::Type encoding); + void setTextEncoding(String::Type encoding); - /*! + /*! * Returns the description for this frame. */ - String description() const; + String description() const; - /*! + /*! * Sets the description of the frame to \a s. \a s must be unique. */ - void setDescription(const String &s); + void setDescription(const String &s); - /*! + /*! * Parses the UserUrlLinkFrame as PropertyMap. The description() is taken as key, * and the URL as single value. * - if description() is empty, the key will be "URL". @@ -161,32 +159,32 @@ namespace TagLib { * characters), the returned map will contain an entry "WXXX/" * in its unsupportedData() list. */ - PropertyMap asProperties() const; + PropertyMap asProperties() const; - /*! + /*! * Searches for the user defined url frame with the description \a description * in \a tag. This returns null if no matching frames were found. */ - static UserUrlLinkFrame *find(Tag *tag, const String &description); + static UserUrlLinkFrame *find(Tag *tag, const String &description); - protected: - virtual void parseFields(const ByteVector &data); - virtual ByteVector renderFields() const; + protected: + virtual void parseFields(const ByteVector &data); + virtual ByteVector renderFields() const; - /*! + /*! * The constructor used by the FrameFactory. */ - UserUrlLinkFrame(const ByteVector &data, Header *h); + UserUrlLinkFrame(const ByteVector &data, Header *h); - private: - UserUrlLinkFrame(const UserUrlLinkFrame &); - UserUrlLinkFrame &operator=(const UserUrlLinkFrame &); + private: + UserUrlLinkFrame(const UserUrlLinkFrame &); + UserUrlLinkFrame &operator=(const UserUrlLinkFrame &); - class UserUrlLinkFramePrivate; - UserUrlLinkFramePrivate *d; - }; + class UserUrlLinkFramePrivate; + UserUrlLinkFramePrivate *d; +}; - } -} -} +} // namespace ID3v2 +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/id3v2/id3v2.h b/3rdparty/taglib/mpeg/id3v2/id3v2.h index 5be5c5098..d8ca26966 100644 --- a/3rdparty/taglib/mpeg/id3v2/id3v2.h +++ b/3rdparty/taglib/mpeg/id3v2/id3v2.h @@ -3,24 +3,24 @@ namespace Strawberry_TagLib { namespace TagLib { - //! An ID3v2 implementation +//! An ID3v2 implementation - /*! +/*! * This is a relatively complete and flexible framework for working with ID3v2 * tags. * * \see ID3v2::Tag */ - namespace ID3v2 { - /*! +namespace ID3v2 { +/*! * Used to specify which version of the ID3 standard to use when saving tags. */ - enum Version { - v3 = 3, //size; } -void ExtendedHeader::setData(const ByteVector &data) -{ +void ExtendedHeader::setData(const ByteVector &data) { parse(data); } @@ -65,7 +59,6 @@ void ExtendedHeader::setData(const ByteVector &data) // protected members //////////////////////////////////////////////////////////////////////////////// -void ExtendedHeader::parse(const ByteVector &data) -{ - d->size = SynchData::toUInt(data.mid(0, 4)); // (structure 3.2 "Extended header size") +void ExtendedHeader::parse(const ByteVector &data) { + d->size = SynchData::toUInt(data.mid(0, 4)); // (structure 3.2 "Extended header size") } diff --git a/3rdparty/taglib/mpeg/id3v2/id3v2extendedheader.h b/3rdparty/taglib/mpeg/id3v2/id3v2extendedheader.h index a952a5563..e7f647ddd 100644 --- a/3rdparty/taglib/mpeg/id3v2/id3v2extendedheader.h +++ b/3rdparty/taglib/mpeg/id3v2/id3v2extendedheader.h @@ -33,11 +33,11 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace ID3v2 { +namespace ID3v2 { - //! ID3v2 extended header implementation +//! ID3v2 extended header implementation - /*! +/*! * This class implements ID3v2 extended headers. It attempts to follow, * both semantically and programmatically, the structure specified in * the ID3v2 standard. The API is based on the properties of ID3v2 extended @@ -46,50 +46,49 @@ namespace TagLib { * (Structure, 3.2) */ - class TAGLIB_EXPORT ExtendedHeader - { - public: - /*! +class TAGLIB_EXPORT ExtendedHeader { + public: + /*! * Constructs an empty ID3v2 extended header. */ - ExtendedHeader(); + ExtendedHeader(); - /*! + /*! * Destroys the extended header. */ - virtual ~ExtendedHeader(); + virtual ~ExtendedHeader(); - /*! + /*! * Returns the size of the extended header. This is variable for the * extended header. */ - unsigned int size() const; + unsigned int size() const; - /*! + /*! * Sets the data that will be used as the extended header. Since the * length is not known before the extended header has been parsed, this * should just be a pointer to the first byte of the extended header. It * will determine the length internally and make that available through * size(). */ - void setData(const ByteVector &data); + void setData(const ByteVector &data); - protected: - /*! + protected: + /*! * Called by setData() to parse the extended header data. It makes this * information available through the public API. */ - void parse(const ByteVector &data); + void parse(const ByteVector &data); - private: - ExtendedHeader(const ExtendedHeader &); - ExtendedHeader &operator=(const ExtendedHeader &); + private: + ExtendedHeader(const ExtendedHeader &); + ExtendedHeader &operator=(const ExtendedHeader &); - class ExtendedHeaderPrivate; - ExtendedHeaderPrivate *d; - }; + class ExtendedHeaderPrivate; + ExtendedHeaderPrivate *d; +}; - } -} -} +} // namespace ID3v2 +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/id3v2/id3v2footer.cpp b/3rdparty/taglib/mpeg/id3v2/id3v2footer.cpp index 169efc8d4..2d4e5c298 100644 --- a/3rdparty/taglib/mpeg/id3v2/id3v2footer.cpp +++ b/3rdparty/taglib/mpeg/id3v2/id3v2footer.cpp @@ -29,26 +29,20 @@ using namespace Strawberry_TagLib::TagLib; using namespace ID3v2; -class Footer::FooterPrivate -{ +class Footer::FooterPrivate { }; -Footer::Footer() : - d(0) -{ +Footer::Footer() : d(0) { } -Footer::~Footer() -{ +Footer::~Footer() { } -unsigned int Footer::size() -{ +unsigned int Footer::size() { return 10; } -ByteVector Footer::render(const Header *header) const -{ +ByteVector Footer::render(const Header *header) const { ByteVector headerData = header->render(); headerData[0] = '3'; headerData[1] = 'D'; diff --git a/3rdparty/taglib/mpeg/id3v2/id3v2footer.h b/3rdparty/taglib/mpeg/id3v2/id3v2footer.h index d17f70024..a6b07cd17 100644 --- a/3rdparty/taglib/mpeg/id3v2/id3v2footer.h +++ b/3rdparty/taglib/mpeg/id3v2/id3v2footer.h @@ -32,13 +32,13 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace ID3v2 { +namespace ID3v2 { - class Header; +class Header; - //! ID3v2 footer implementation +//! ID3v2 footer implementation - /*! +/*! * Per the ID3v2 specification, the tag's footer is just a copy of the * information in the header. As such there is no API for reading the * data from the header, it can just as easily be done from the header. @@ -48,37 +48,36 @@ namespace TagLib { * has been set in the ID3v2::Tag, TagLib will render a footer. */ - class TAGLIB_EXPORT Footer - { - public: - /*! +class TAGLIB_EXPORT Footer { + public: + /*! * Constructs an empty ID3v2 footer. */ - Footer(); - /*! + Footer(); + /*! * Destroys the footer. */ - virtual ~Footer(); + virtual ~Footer(); - /*! + /*! * Returns the size of the footer. Presently this is always 10 bytes. */ - static unsigned int size(); + static unsigned int size(); - /*! + /*! * Renders the footer based on the data in \a header. */ - ByteVector render(const Header *header) const; + ByteVector render(const Header *header) const; - private: - Footer(const Footer &); - Footer &operator=(const Footer &); + private: + Footer(const Footer &); + Footer &operator=(const Footer &); - class FooterPrivate; - FooterPrivate *d; - }; + class FooterPrivate; + FooterPrivate *d; +}; - } -} -} +} // namespace ID3v2 +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/id3v2/id3v2frame.cpp b/3rdparty/taglib/mpeg/id3v2/id3v2frame.cpp index 70b85536f..aa96c45e4 100644 --- a/3rdparty/taglib/mpeg/id3v2/id3v2frame.cpp +++ b/3rdparty/taglib/mpeg/id3v2/id3v2frame.cpp @@ -44,54 +44,46 @@ using namespace Strawberry_TagLib::TagLib; using namespace ID3v2; -class Frame::FramePrivate -{ -public: - FramePrivate() : - header(0) - {} +class Frame::FramePrivate { + public: + FramePrivate() : header(0) { + } - ~FramePrivate() - { + ~FramePrivate() { delete header; } Frame::Header *header; }; -namespace -{ - bool isValidFrameID(const ByteVector &frameID) - { - if(frameID.size() != 4) - return false; +namespace { +bool isValidFrameID(const ByteVector &frameID) { + if (frameID.size() != 4) + return false; - for(ByteVector::ConstIterator it = frameID.begin(); it != frameID.end(); it++) { - if( (*it < 'A' || *it > 'Z') && (*it < '0' || *it > '9') ) { - return false; - } + for (ByteVector::ConstIterator it = frameID.begin(); it != frameID.end(); it++) { + if ((*it < 'A' || *it > 'Z') && (*it < '0' || *it > '9')) { + return false; } - return true; } + return true; } +} // namespace //////////////////////////////////////////////////////////////////////////////// // static methods //////////////////////////////////////////////////////////////////////////////// -unsigned int Frame::headerSize() -{ +unsigned int Frame::headerSize() { return Header::size(); } -unsigned int Frame::headerSize(unsigned int version) -{ +unsigned int Frame::headerSize(unsigned int version) { return Header::size(version); } -ByteVector Frame::textDelimiter(String::Type t) -{ - if(t == String::UTF16 || t == String::UTF16BE || t == String::UTF16LE) +ByteVector Frame::textDelimiter(String::Type t) { + if (t == String::UTF16 || t == String::UTF16BE || t == String::UTF16LE) return ByteVector(2, '\0'); else return ByteVector(1, '\0'); @@ -106,45 +98,46 @@ const String Frame::urlPrefix("URL:"); // public members //////////////////////////////////////////////////////////////////////////////// -Frame *Frame::createTextualFrame(const String &key, const StringList &values) //static +Frame *Frame::createTextualFrame(const String &key, const StringList &values) //static { // check if the key is contained in the key<=>frameID mapping ByteVector frameID = keyToFrameID(key); - if(!frameID.isEmpty()) { + if (!frameID.isEmpty()) { // Apple proprietary WFED (Podcast URL), MVNM (Movement Name), MVIN (Movement Number), GRP1 (Grouping) are in fact text frames. - if(frameID[0] == 'T' || frameID == "WFED" || frameID == "MVNM" || frameID == "MVIN" || frameID == "GRP1"){ // text frame + if (frameID[0] == 'T' || frameID == "WFED" || frameID == "MVNM" || frameID == "MVIN" || frameID == "GRP1") { // text frame TextIdentificationFrame *frame = new TextIdentificationFrame(frameID, String::UTF8); frame->setText(values); return frame; - } else if((frameID[0] == 'W') && (values.size() == 1)){ // URL frame (not WXXX); support only one value - UrlLinkFrame* frame = new UrlLinkFrame(frameID); - frame->setUrl(values.front()); - return frame; + } + else if ((frameID[0] == 'W') && (values.size() == 1)) { // URL frame (not WXXX); support only one value + UrlLinkFrame *frame = new UrlLinkFrame(frameID); + frame->setUrl(values.front()); + return frame; } } - if(key == "MUSICBRAINZ_TRACKID" && values.size() == 1) { + if (key == "MUSICBRAINZ_TRACKID" && values.size() == 1) { UniqueFileIdentifierFrame *frame = new UniqueFileIdentifierFrame("http://musicbrainz.org", values.front().data(String::UTF8)); return frame; } // now we check if it's one of the "special" cases: // -LYRICS: depending on the number of values, use USLT or TXXX (with description=LYRICS) - if((key == "LYRICS" || key.startsWith(lyricsPrefix)) && values.size() == 1){ + if ((key == "LYRICS" || key.startsWith(lyricsPrefix)) && values.size() == 1) { UnsynchronizedLyricsFrame *frame = new UnsynchronizedLyricsFrame(String::UTF8); frame->setDescription(key == "LYRICS" ? key : key.substr(lyricsPrefix.size())); frame->setText(values.front()); return frame; } // -URL: depending on the number of values, use WXXX or TXXX (with description=URL) - if((key == "URL" || key.startsWith(urlPrefix)) && values.size() == 1){ + if ((key == "URL" || key.startsWith(urlPrefix)) && values.size() == 1) { UserUrlLinkFrame *frame = new UserUrlLinkFrame(String::UTF8); frame->setDescription(key == "URL" ? key : key.substr(urlPrefix.size())); frame->setUrl(values.front()); return frame; } // -COMMENT: depending on the number of values, use COMM or TXXX (with description=COMMENT) - if((key == "COMMENT" || key.startsWith(commentPrefix)) && values.size() == 1){ + if ((key == "COMMENT" || key.startsWith(commentPrefix)) && values.size() == 1) { CommentsFrame *frame = new CommentsFrame(String::UTF8); - if (key != "COMMENT"){ + if (key != "COMMENT") { frame->setDescription(key.substr(commentPrefix.size())); } frame->setText(values.front()); @@ -154,39 +147,32 @@ Frame *Frame::createTextualFrame(const String &key, const StringList &values) // return new UserTextIdentificationFrame(keyToTXXX(key), values, String::UTF8); } -Frame::~Frame() -{ +Frame::~Frame() { delete d; } -ByteVector Frame::frameID() const -{ - if(d->header) +ByteVector Frame::frameID() const { + if (d->header) return d->header->frameID(); else return ByteVector(); } -unsigned int Frame::size() const -{ - if(d->header) +unsigned int Frame::size() const { + if (d->header) return d->header->frameSize(); else return 0; } -void Frame::setData(const ByteVector &data) -{ +void Frame::setData(const ByteVector &data) { parse(data); } -void Frame::setText(const String &) -{ - +void Frame::setText(const String &) { } -ByteVector Frame::render() const -{ +ByteVector Frame::render() const { ByteVector fieldData = renderFields(); d->header->setFrameSize(fieldData.size()); ByteVector headerData = d->header->render(); @@ -198,34 +184,27 @@ ByteVector Frame::render() const // protected members //////////////////////////////////////////////////////////////////////////////// -Frame::Frame(const ByteVector &data) : - d(new FramePrivate()) -{ +Frame::Frame(const ByteVector &data) : d(new FramePrivate()) { d->header = new Header(data); } -Frame::Frame(Header *h) : - d(new FramePrivate()) -{ +Frame::Frame(Header *h) : d(new FramePrivate()) { d->header = h; } -Frame::Header *Frame::header() const -{ +Frame::Header *Frame::header() const { return d->header; } -void Frame::setHeader(Header *h, bool deleteCurrent) -{ - if(deleteCurrent) +void Frame::setHeader(Header *h, bool deleteCurrent) { + if (deleteCurrent) delete d->header; d->header = h; } -void Frame::parse(const ByteVector &data) -{ - if(d->header) +void Frame::parse(const ByteVector &data) { + if (d->header) d->header->setData(data); else d->header = new Header(data); @@ -233,26 +212,25 @@ void Frame::parse(const ByteVector &data) parseFields(fieldData(data)); } -ByteVector Frame::fieldData(const ByteVector &frameData) const -{ +ByteVector Frame::fieldData(const ByteVector &frameData) const { unsigned int headerSize = Header::size(d->header->version()); unsigned int frameDataOffset = headerSize; unsigned int frameDataLength = size(); - if(d->header->compression() || d->header->dataLengthIndicator()) { + if (d->header->compression() || d->header->dataLengthIndicator()) { frameDataLength = SynchData::toUInt(frameData.mid(headerSize, 4)); frameDataOffset += 4; } - if(zlib::isAvailable() && d->header->compression() && !d->header->encryption()) { - if(frameData.size() <= frameDataOffset) { + if (zlib::isAvailable() && d->header->compression() && !d->header->encryption()) { + if (frameData.size() <= frameDataOffset) { debug("Compressed frame doesn't have enough data to decode"); return ByteVector(); } const ByteVector outData = zlib::decompress(frameData.mid(frameDataOffset)); - if(!outData.isEmpty() && frameDataLength != outData.size()) { + if (!outData.isEmpty() && frameDataLength != outData.size()) { debug("frameDataLength does not match the data length returned by zlib"); } @@ -262,22 +240,21 @@ ByteVector Frame::fieldData(const ByteVector &frameData) const return frameData.mid(frameDataOffset, frameDataLength); } -String Frame::readStringField(const ByteVector &data, String::Type encoding, int *position) -{ +String Frame::readStringField(const ByteVector &data, String::Type encoding, int *position) { int start = 0; - if(!position) + if (!position) position = &start; ByteVector delimiter = textDelimiter(encoding); int end = data.find(delimiter, *position, delimiter.size()); - if(end < *position) + if (end < *position) return String(); String str; - if(encoding == String::Latin1) + if (encoding == String::Latin1) str = Tag::latin1StringHandler()->parse(data.mid(*position, end - *position)); else str = String(data.mid(*position, end - *position), encoding); @@ -287,22 +264,22 @@ String Frame::readStringField(const ByteVector &data, String::Type encoding, int return str; } -String::Type Frame::checkEncoding(const StringList &fields, String::Type encoding) // static +String::Type Frame::checkEncoding(const StringList &fields, String::Type encoding) // static { return checkEncoding(fields, encoding, 4); } -String::Type Frame::checkEncoding(const StringList &fields, String::Type encoding, unsigned int version) // static +String::Type Frame::checkEncoding(const StringList &fields, String::Type encoding, unsigned int version) // static { - if((encoding == String::UTF8 || encoding == String::UTF16BE) && version != 4) + if ((encoding == String::UTF8 || encoding == String::UTF16BE) && version != 4) return String::UTF16; - if(encoding != String::Latin1) + if (encoding != String::Latin1) return encoding; - for(StringList::ConstIterator it = fields.begin(); it != fields.end(); ++it) { - if(!(*it).isLatin1()) { - if(version == 4) { + for (StringList::ConstIterator it = fields.begin(); it != fields.end(); ++it) { + if (!(*it).isLatin1()) { + if (version == 4) { debug("Frame::checkEncoding() -- Rendering using UTF8."); return String::UTF8; } @@ -316,195 +293,187 @@ String::Type Frame::checkEncoding(const StringList &fields, String::Type encodin return String::Latin1; } -String::Type Frame::checkTextEncoding(const StringList &fields, String::Type encoding) const -{ +String::Type Frame::checkTextEncoding(const StringList &fields, String::Type encoding) const { return checkEncoding(fields, encoding, header()->version()); } -namespace -{ - const char *frameTranslation[][2] = { - // Text information frames - { "TALB", "ALBUM"}, - { "TBPM", "BPM" }, - { "TCOM", "COMPOSER" }, - { "TCON", "GENRE" }, - { "TCOP", "COPYRIGHT" }, - { "TDEN", "ENCODINGTIME" }, - { "TDLY", "PLAYLISTDELAY" }, - { "TDOR", "ORIGINALDATE" }, - { "TDRC", "DATE" }, - // { "TRDA", "DATE" }, // id3 v2.3, replaced by TDRC in v2.4 - // { "TDAT", "DATE" }, // id3 v2.3, replaced by TDRC in v2.4 - // { "TYER", "DATE" }, // id3 v2.3, replaced by TDRC in v2.4 - // { "TIME", "DATE" }, // id3 v2.3, replaced by TDRC in v2.4 - { "TDRL", "RELEASEDATE" }, - { "TDTG", "TAGGINGDATE" }, - { "TENC", "ENCODEDBY" }, - { "TEXT", "LYRICIST" }, - { "TFLT", "FILETYPE" }, - //{ "TIPL", "INVOLVEDPEOPLE" }, handled separately - { "TIT1", "CONTENTGROUP" }, - { "TIT2", "TITLE"}, - { "TIT3", "SUBTITLE" }, - { "TKEY", "INITIALKEY" }, - { "TLAN", "LANGUAGE" }, - { "TLEN", "LENGTH" }, - //{ "TMCL", "MUSICIANCREDITS" }, handled separately - { "TMED", "MEDIA" }, - { "TMOO", "MOOD" }, - { "TOAL", "ORIGINALALBUM" }, - { "TOFN", "ORIGINALFILENAME" }, - { "TOLY", "ORIGINALLYRICIST" }, - { "TOPE", "ORIGINALARTIST" }, - { "TOWN", "OWNER" }, - { "TPE1", "ARTIST"}, - { "TPE2", "ALBUMARTIST" }, // id3's spec says 'PERFORMER', but most programs use 'ALBUMARTIST' - { "TPE3", "CONDUCTOR" }, - { "TPE4", "REMIXER" }, // could also be ARRANGER - { "TPOS", "DISCNUMBER" }, - { "TPRO", "PRODUCEDNOTICE" }, - { "TPUB", "LABEL" }, - { "TRCK", "TRACKNUMBER" }, - { "TRSN", "RADIOSTATION" }, - { "TRSO", "RADIOSTATIONOWNER" }, - { "TSOA", "ALBUMSORT" }, - { "TSOP", "ARTISTSORT" }, - { "TSOT", "TITLESORT" }, - { "TSO2", "ALBUMARTISTSORT" }, // non-standard, used by iTunes - { "TSRC", "ISRC" }, - { "TSSE", "ENCODING" }, - // URL frames - { "WCOP", "COPYRIGHTURL" }, - { "WOAF", "FILEWEBPAGE" }, - { "WOAR", "ARTISTWEBPAGE" }, - { "WOAS", "AUDIOSOURCEWEBPAGE" }, - { "WORS", "RADIOSTATIONWEBPAGE" }, - { "WPAY", "PAYMENTWEBPAGE" }, - { "WPUB", "PUBLISHERWEBPAGE" }, - //{ "WXXX", "URL"}, handled specially - // Other frames - { "COMM", "COMMENT" }, - //{ "USLT", "LYRICS" }, handled specially - // Apple iTunes proprietary frames - { "PCST", "PODCAST" }, - { "TCAT", "PODCASTCATEGORY" }, - { "TDES", "PODCASTDESC" }, - { "TGID", "PODCASTID" }, - { "WFED", "PODCASTURL" }, - { "MVNM", "MOVEMENTNAME" }, - { "MVIN", "MOVEMENTNUMBER" }, - { "GRP1", "GROUPING" }, - }; - const size_t frameTranslationSize = sizeof(frameTranslation) / sizeof(frameTranslation[0]); +namespace { +const char *frameTranslation[][2] = { + // Text information frames + { "TALB", "ALBUM" }, + { "TBPM", "BPM" }, + { "TCOM", "COMPOSER" }, + { "TCON", "GENRE" }, + { "TCOP", "COPYRIGHT" }, + { "TDEN", "ENCODINGTIME" }, + { "TDLY", "PLAYLISTDELAY" }, + { "TDOR", "ORIGINALDATE" }, + { "TDRC", "DATE" }, + // { "TRDA", "DATE" }, // id3 v2.3, replaced by TDRC in v2.4 + // { "TDAT", "DATE" }, // id3 v2.3, replaced by TDRC in v2.4 + // { "TYER", "DATE" }, // id3 v2.3, replaced by TDRC in v2.4 + // { "TIME", "DATE" }, // id3 v2.3, replaced by TDRC in v2.4 + { "TDRL", "RELEASEDATE" }, + { "TDTG", "TAGGINGDATE" }, + { "TENC", "ENCODEDBY" }, + { "TEXT", "LYRICIST" }, + { "TFLT", "FILETYPE" }, + //{ "TIPL", "INVOLVEDPEOPLE" }, handled separately + { "TIT1", "CONTENTGROUP" }, + { "TIT2", "TITLE" }, + { "TIT3", "SUBTITLE" }, + { "TKEY", "INITIALKEY" }, + { "TLAN", "LANGUAGE" }, + { "TLEN", "LENGTH" }, + //{ "TMCL", "MUSICIANCREDITS" }, handled separately + { "TMED", "MEDIA" }, + { "TMOO", "MOOD" }, + { "TOAL", "ORIGINALALBUM" }, + { "TOFN", "ORIGINALFILENAME" }, + { "TOLY", "ORIGINALLYRICIST" }, + { "TOPE", "ORIGINALARTIST" }, + { "TOWN", "OWNER" }, + { "TPE1", "ARTIST" }, + { "TPE2", "ALBUMARTIST" }, // id3's spec says 'PERFORMER', but most programs use 'ALBUMARTIST' + { "TPE3", "CONDUCTOR" }, + { "TPE4", "REMIXER" }, // could also be ARRANGER + { "TPOS", "DISCNUMBER" }, + { "TPRO", "PRODUCEDNOTICE" }, + { "TPUB", "LABEL" }, + { "TRCK", "TRACKNUMBER" }, + { "TRSN", "RADIOSTATION" }, + { "TRSO", "RADIOSTATIONOWNER" }, + { "TSOA", "ALBUMSORT" }, + { "TSOP", "ARTISTSORT" }, + { "TSOT", "TITLESORT" }, + { "TSO2", "ALBUMARTISTSORT" }, // non-standard, used by iTunes + { "TSRC", "ISRC" }, + { "TSSE", "ENCODING" }, + // URL frames + { "WCOP", "COPYRIGHTURL" }, + { "WOAF", "FILEWEBPAGE" }, + { "WOAR", "ARTISTWEBPAGE" }, + { "WOAS", "AUDIOSOURCEWEBPAGE" }, + { "WORS", "RADIOSTATIONWEBPAGE" }, + { "WPAY", "PAYMENTWEBPAGE" }, + { "WPUB", "PUBLISHERWEBPAGE" }, + //{ "WXXX", "URL"}, handled specially + // Other frames + { "COMM", "COMMENT" }, + //{ "USLT", "LYRICS" }, handled specially + // Apple iTunes proprietary frames + { "PCST", "PODCAST" }, + { "TCAT", "PODCASTCATEGORY" }, + { "TDES", "PODCASTDESC" }, + { "TGID", "PODCASTID" }, + { "WFED", "PODCASTURL" }, + { "MVNM", "MOVEMENTNAME" }, + { "MVIN", "MOVEMENTNUMBER" }, + { "GRP1", "GROUPING" }, +}; +const size_t frameTranslationSize = sizeof(frameTranslation) / sizeof(frameTranslation[0]); - const char *txxxFrameTranslation[][2] = { - { "MUSICBRAINZ ALBUM ID", "MUSICBRAINZ_ALBUMID" }, - { "MUSICBRAINZ ARTIST ID", "MUSICBRAINZ_ARTISTID" }, - { "MUSICBRAINZ ALBUM ARTIST ID", "MUSICBRAINZ_ALBUMARTISTID" }, - { "MUSICBRAINZ RELEASE GROUP ID", "MUSICBRAINZ_RELEASEGROUPID" }, - { "MUSICBRAINZ WORK ID", "MUSICBRAINZ_WORKID" }, - { "ACOUSTID ID", "ACOUSTID_ID" }, - { "ACOUSTID FINGERPRINT", "ACOUSTID_FINGERPRINT" }, - { "MUSICIP PUID", "MUSICIP_PUID" }, - }; - const size_t txxxFrameTranslationSize = sizeof(txxxFrameTranslation) / sizeof(txxxFrameTranslation[0]); +const char *txxxFrameTranslation[][2] = { + { "MUSICBRAINZ ALBUM ID", "MUSICBRAINZ_ALBUMID" }, + { "MUSICBRAINZ ARTIST ID", "MUSICBRAINZ_ARTISTID" }, + { "MUSICBRAINZ ALBUM ARTIST ID", "MUSICBRAINZ_ALBUMARTISTID" }, + { "MUSICBRAINZ RELEASE GROUP ID", "MUSICBRAINZ_RELEASEGROUPID" }, + { "MUSICBRAINZ WORK ID", "MUSICBRAINZ_WORKID" }, + { "ACOUSTID ID", "ACOUSTID_ID" }, + { "ACOUSTID FINGERPRINT", "ACOUSTID_FINGERPRINT" }, + { "MUSICIP PUID", "MUSICIP_PUID" }, +}; +const size_t txxxFrameTranslationSize = sizeof(txxxFrameTranslation) / sizeof(txxxFrameTranslation[0]); - // list of deprecated frames and their successors - const char *deprecatedFrames[][2] = { - {"TRDA", "TDRC"}, // 2.3 -> 2.4 (http://en.wikipedia.org/wiki/ID3) - {"TDAT", "TDRC"}, // 2.3 -> 2.4 - {"TYER", "TDRC"}, // 2.3 -> 2.4 - {"TIME", "TDRC"}, // 2.3 -> 2.4 - }; - const size_t deprecatedFramesSize = sizeof(deprecatedFrames) / sizeof(deprecatedFrames[0]); -} +// list of deprecated frames and their successors +const char *deprecatedFrames[][2] = { + { "TRDA", "TDRC" }, // 2.3 -> 2.4 (http://en.wikipedia.org/wiki/ID3) + { "TDAT", "TDRC" }, // 2.3 -> 2.4 + { "TYER", "TDRC" }, // 2.3 -> 2.4 + { "TIME", "TDRC" }, // 2.3 -> 2.4 +}; +const size_t deprecatedFramesSize = sizeof(deprecatedFrames) / sizeof(deprecatedFrames[0]); +} // namespace -String Frame::frameIDToKey(const ByteVector &id) -{ +String Frame::frameIDToKey(const ByteVector &id) { ByteVector id24 = id; - for(size_t i = 0; i < deprecatedFramesSize; ++i) { - if(id24 == deprecatedFrames[i][0]) { + for (size_t i = 0; i < deprecatedFramesSize; ++i) { + if (id24 == deprecatedFrames[i][0]) { id24 = deprecatedFrames[i][1]; break; } } - for(size_t i = 0; i < frameTranslationSize; ++i) { - if(id24 == frameTranslation[i][0]) + for (size_t i = 0; i < frameTranslationSize; ++i) { + if (id24 == frameTranslation[i][0]) return frameTranslation[i][1]; } return String(); } -ByteVector Frame::keyToFrameID(const String &s) -{ +ByteVector Frame::keyToFrameID(const String &s) { const String key = s.upper(); - for(size_t i = 0; i < frameTranslationSize; ++i) { - if(key == frameTranslation[i][1]) + for (size_t i = 0; i < frameTranslationSize; ++i) { + if (key == frameTranslation[i][1]) return frameTranslation[i][0]; } return ByteVector(); } -String Frame::txxxToKey(const String &description) -{ +String Frame::txxxToKey(const String &description) { const String d = description.upper(); - for(size_t i = 0; i < txxxFrameTranslationSize; ++i) { - if(d == txxxFrameTranslation[i][0]) + for (size_t i = 0; i < txxxFrameTranslationSize; ++i) { + if (d == txxxFrameTranslation[i][0]) return txxxFrameTranslation[i][1]; } return d; } -String Frame::keyToTXXX(const String &s) -{ +String Frame::keyToTXXX(const String &s) { const String key = s.upper(); - for(size_t i = 0; i < txxxFrameTranslationSize; ++i) { - if(key == txxxFrameTranslation[i][1]) + for (size_t i = 0; i < txxxFrameTranslationSize; ++i) { + if (key == txxxFrameTranslation[i][1]) return txxxFrameTranslation[i][0]; } return s; } -PropertyMap Frame::asProperties() const -{ - if(dynamic_cast< const UnknownFrame *>(this)) { +PropertyMap Frame::asProperties() const { + if (dynamic_cast(this)) { PropertyMap m; m.unsupportedData().append("UNKNOWN/" + frameID()); return m; } const ByteVector &id = frameID(); // workaround until this function is virtual - if(id == "TXXX") - return dynamic_cast< const UserTextIdentificationFrame* >(this)->asProperties(); + if (id == "TXXX") + return dynamic_cast(this)->asProperties(); // Apple proprietary WFED (Podcast URL), MVNM (Movement Name), MVIN (Movement Number), GRP1 (Grouping) are in fact text frames. - else if(id[0] == 'T' || id == "WFED" || id == "MVNM" || id == "MVIN" || id == "GRP1") - return dynamic_cast< const TextIdentificationFrame* >(this)->asProperties(); - else if(id == "WXXX") - return dynamic_cast< const UserUrlLinkFrame* >(this)->asProperties(); - else if(id[0] == 'W') - return dynamic_cast< const UrlLinkFrame* >(this)->asProperties(); - else if(id == "COMM") - return dynamic_cast< const CommentsFrame* >(this)->asProperties(); - else if(id == "USLT") - return dynamic_cast< const UnsynchronizedLyricsFrame* >(this)->asProperties(); - else if(id == "UFID") - return dynamic_cast< const UniqueFileIdentifierFrame* >(this)->asProperties(); + else if (id[0] == 'T' || id == "WFED" || id == "MVNM" || id == "MVIN" || id == "GRP1") + return dynamic_cast(this)->asProperties(); + else if (id == "WXXX") + return dynamic_cast(this)->asProperties(); + else if (id[0] == 'W') + return dynamic_cast(this)->asProperties(); + else if (id == "COMM") + return dynamic_cast(this)->asProperties(); + else if (id == "USLT") + return dynamic_cast(this)->asProperties(); + else if (id == "UFID") + return dynamic_cast(this)->asProperties(); PropertyMap m; m.unsupportedData().append(id); return m; } void Frame::splitProperties(const PropertyMap &original, PropertyMap &singleFrameProperties, - PropertyMap &tiplProperties, PropertyMap &tmclProperties) -{ + PropertyMap &tiplProperties, PropertyMap &tmclProperties) { singleFrameProperties.clear(); tiplProperties.clear(); tmclProperties.clear(); - for(PropertyMap::ConstIterator it = original.begin(); it != original.end(); ++it) { - if(TextIdentificationFrame::involvedPeopleMap().contains(it->first)) + for (PropertyMap::ConstIterator it = original.begin(); it != original.end(); ++it) { + if (TextIdentificationFrame::involvedPeopleMap().contains(it->first)) tiplProperties.insert(it->first, it->second); - else if(it->first.startsWith(TextIdentificationFrame::instrumentPrefix)) + else if (it->first.startsWith(TextIdentificationFrame::instrumentPrefix)) tmclProperties.insert(it->first, it->second); else singleFrameProperties.insert(it->first, it->second); @@ -515,21 +484,19 @@ void Frame::splitProperties(const PropertyMap &original, PropertyMap &singleFram // Frame::Header class //////////////////////////////////////////////////////////////////////////////// -class Frame::Header::HeaderPrivate -{ -public: - HeaderPrivate() : - frameSize(0), - version(4), - tagAlterPreservation(false), - fileAlterPreservation(false), - readOnly(false), - groupingIdentity(false), - compression(false), - encryption(false), - unsynchronisation(false), - dataLengthIndicator(false) - {} +class Frame::Header::HeaderPrivate { + public: + HeaderPrivate() : frameSize(0), + version(4), + tagAlterPreservation(false), + fileAlterPreservation(false), + readOnly(false), + groupingIdentity(false), + compression(false), + encryption(false), + unsynchronisation(false), + dataLengthIndicator(false) { + } ByteVector frameID; unsigned int frameSize; @@ -551,22 +518,20 @@ public: // static members (Frame::Header) //////////////////////////////////////////////////////////////////////////////// -unsigned int Frame::Header::size() -{ +unsigned int Frame::Header::size() { return size(4); } -unsigned int Frame::Header::size(unsigned int version) -{ - switch(version) { - case 0: - case 1: - case 2: - return 6; - case 3: - case 4: - default: - return 10; +unsigned int Frame::Header::size(unsigned int version) { + switch (version) { + case 0: + case 1: + case 2: + return 6; + case 3: + case 4: + default: + return 10; } } @@ -574,253 +539,223 @@ unsigned int Frame::Header::size(unsigned int version) // public members (Frame::Header) //////////////////////////////////////////////////////////////////////////////// -Frame::Header::Header(const ByteVector &data, bool synchSafeInts) : - d(new HeaderPrivate()) -{ +Frame::Header::Header(const ByteVector &data, bool synchSafeInts) : d(new HeaderPrivate()) { setData(data, synchSafeInts); } -Frame::Header::Header(const ByteVector &data, unsigned int version) : - d(new HeaderPrivate()) -{ +Frame::Header::Header(const ByteVector &data, unsigned int version) : d(new HeaderPrivate()) { setData(data, version); } -Frame::Header::~Header() -{ +Frame::Header::~Header() { delete d; } -void Frame::Header::setData(const ByteVector &data, bool synchSafeInts) -{ +void Frame::Header::setData(const ByteVector &data, bool synchSafeInts) { setData(data, static_cast(synchSafeInts ? 4 : 3)); } -void Frame::Header::setData(const ByteVector &data, unsigned int version) -{ +void Frame::Header::setData(const ByteVector &data, unsigned int version) { d->version = version; - switch(version) { - case 0: - case 1: - case 2: - { - // ID3v2.2 + switch (version) { + case 0: + case 1: + case 2: { + // ID3v2.2 - if(data.size() < 3) { - debug("You must at least specify a frame ID."); - return; + if (data.size() < 3) { + debug("You must at least specify a frame ID."); + return; + } + + // Set the frame ID -- the first three bytes + + d->frameID = data.mid(0, 3); + + // If the full header information was not passed in, do not continue to the + // steps to parse the frame size and flags. + + if (data.size() < 6) { + d->frameSize = 0; + return; + } + + d->frameSize = data.toUInt(3, 3, true); + + break; } + case 3: { + // ID3v2.3 - // Set the frame ID -- the first three bytes + if (data.size() < 4) { + debug("You must at least specify a frame ID."); + return; + } - d->frameID = data.mid(0, 3); + // Set the frame ID -- the first four bytes - // If the full header information was not passed in, do not continue to the - // steps to parse the frame size and flags. + d->frameID = data.mid(0, 4); - if(data.size() < 6) { - d->frameSize = 0; - return; + // If the full header information was not passed in, do not continue to the + // steps to parse the frame size and flags. + + if (data.size() < 10) { + d->frameSize = 0; + return; + } + + // Set the size -- the frame size is the four bytes starting at byte four in + // the frame header (structure 4) + + d->frameSize = data.toUInt(4U); + + { // read the first byte of flags + std::bitset<8> flags(data[8]); + d->tagAlterPreservation = flags[7]; // (structure 3.3.1.a) + d->fileAlterPreservation = flags[6]; // (structure 3.3.1.b) + d->readOnly = flags[5]; // (structure 3.3.1.c) + } + + { // read the second byte of flags + std::bitset<8> flags(data[9]); + d->compression = flags[7]; // (structure 3.3.1.i) + d->encryption = flags[6]; // (structure 3.3.1.j) + d->groupingIdentity = flags[5]; // (structure 3.3.1.k) + } + break; } + case 4: + default: { + // ID3v2.4 - d->frameSize = data.toUInt(3, 3, true); + if (data.size() < 4) { + debug("You must at least specify a frame ID."); + return; + } - break; - } - case 3: - { - // ID3v2.3 + // Set the frame ID -- the first four bytes - if(data.size() < 4) { - debug("You must at least specify a frame ID."); - return; - } + d->frameID = data.mid(0, 4); - // Set the frame ID -- the first four bytes + // If the full header information was not passed in, do not continue to the + // steps to parse the frame size and flags. - d->frameID = data.mid(0, 4); + if (data.size() < 10) { + d->frameSize = 0; + return; + } - // If the full header information was not passed in, do not continue to the - // steps to parse the frame size and flags. + // Set the size -- the frame size is the four bytes starting at byte four in + // the frame header (structure 4) - if(data.size() < 10) { - d->frameSize = 0; - return; - } - - // Set the size -- the frame size is the four bytes starting at byte four in - // the frame header (structure 4) - - d->frameSize = data.toUInt(4U); - - { // read the first byte of flags - std::bitset<8> flags(data[8]); - d->tagAlterPreservation = flags[7]; // (structure 3.3.1.a) - d->fileAlterPreservation = flags[6]; // (structure 3.3.1.b) - d->readOnly = flags[5]; // (structure 3.3.1.c) - } - - { // read the second byte of flags - std::bitset<8> flags(data[9]); - d->compression = flags[7]; // (structure 3.3.1.i) - d->encryption = flags[6]; // (structure 3.3.1.j) - d->groupingIdentity = flags[5]; // (structure 3.3.1.k) - } - break; - } - case 4: - default: - { - // ID3v2.4 - - if(data.size() < 4) { - debug("You must at least specify a frame ID."); - return; - } - - // Set the frame ID -- the first four bytes - - d->frameID = data.mid(0, 4); - - // If the full header information was not passed in, do not continue to the - // steps to parse the frame size and flags. - - if(data.size() < 10) { - d->frameSize = 0; - return; - } - - // Set the size -- the frame size is the four bytes starting at byte four in - // the frame header (structure 4) - - d->frameSize = SynchData::toUInt(data.mid(4, 4)); + d->frameSize = SynchData::toUInt(data.mid(4, 4)); #ifndef NO_ITUNES_HACKS - // iTunes writes v2.4 tags with v2.3-like frame sizes - if(d->frameSize > 127) { - if(!isValidFrameID(data.mid(d->frameSize + 10, 4))) { - unsigned int uintSize = data.toUInt(4U); - if(isValidFrameID(data.mid(uintSize + 10, 4))) { - d->frameSize = uintSize; + // iTunes writes v2.4 tags with v2.3-like frame sizes + if (d->frameSize > 127) { + if (!isValidFrameID(data.mid(d->frameSize + 10, 4))) { + unsigned int uintSize = data.toUInt(4U); + if (isValidFrameID(data.mid(uintSize + 10, 4))) { + d->frameSize = uintSize; + } } } - } #endif - { // read the first byte of flags - std::bitset<8> flags(data[8]); - d->tagAlterPreservation = flags[6]; // (structure 4.1.1.a) - d->fileAlterPreservation = flags[5]; // (structure 4.1.1.b) - d->readOnly = flags[4]; // (structure 4.1.1.c) - } + { // read the first byte of flags + std::bitset<8> flags(data[8]); + d->tagAlterPreservation = flags[6]; // (structure 4.1.1.a) + d->fileAlterPreservation = flags[5]; // (structure 4.1.1.b) + d->readOnly = flags[4]; // (structure 4.1.1.c) + } - { // read the second byte of flags - std::bitset<8> flags(data[9]); - d->groupingIdentity = flags[6]; // (structure 4.1.2.h) - d->compression = flags[3]; // (structure 4.1.2.k) - d->encryption = flags[2]; // (structure 4.1.2.m) - d->unsynchronisation = flags[1]; // (structure 4.1.2.n) - d->dataLengthIndicator = flags[0]; // (structure 4.1.2.p) + { // read the second byte of flags + std::bitset<8> flags(data[9]); + d->groupingIdentity = flags[6]; // (structure 4.1.2.h) + d->compression = flags[3]; // (structure 4.1.2.k) + d->encryption = flags[2]; // (structure 4.1.2.m) + d->unsynchronisation = flags[1]; // (structure 4.1.2.n) + d->dataLengthIndicator = flags[0]; // (structure 4.1.2.p) + } + break; } - break; - } } } -ByteVector Frame::Header::frameID() const -{ +ByteVector Frame::Header::frameID() const { return d->frameID; } -void Frame::Header::setFrameID(const ByteVector &id) -{ +void Frame::Header::setFrameID(const ByteVector &id) { d->frameID = id.mid(0, 4); } -unsigned int Frame::Header::frameSize() const -{ +unsigned int Frame::Header::frameSize() const { return d->frameSize; } -void Frame::Header::setFrameSize(unsigned int size) -{ +void Frame::Header::setFrameSize(unsigned int size) { d->frameSize = size; } -unsigned int Frame::Header::version() const -{ +unsigned int Frame::Header::version() const { return d->version; } -void Frame::Header::setVersion(unsigned int version) -{ +void Frame::Header::setVersion(unsigned int version) { d->version = version; } -bool Frame::Header::tagAlterPreservation() const -{ +bool Frame::Header::tagAlterPreservation() const { return d->tagAlterPreservation; } -void Frame::Header::setTagAlterPreservation(bool preserve) -{ +void Frame::Header::setTagAlterPreservation(bool preserve) { d->tagAlterPreservation = preserve; } -bool Frame::Header::fileAlterPreservation() const -{ +bool Frame::Header::fileAlterPreservation() const { return d->fileAlterPreservation; } -bool Frame::Header::readOnly() const -{ +bool Frame::Header::readOnly() const { return d->readOnly; } -bool Frame::Header::groupingIdentity() const -{ +bool Frame::Header::groupingIdentity() const { return d->groupingIdentity; } -bool Frame::Header::compression() const -{ +bool Frame::Header::compression() const { return d->compression; } -bool Frame::Header::encryption() const -{ +bool Frame::Header::encryption() const { return d->encryption; } -bool Frame::Header::unsycronisation() const -{ +bool Frame::Header::unsycronisation() const { return unsynchronisation(); } -bool Frame::Header::unsynchronisation() const -{ +bool Frame::Header::unsynchronisation() const { return d->unsynchronisation; } -bool Frame::Header::dataLengthIndicator() const -{ +bool Frame::Header::dataLengthIndicator() const { return d->dataLengthIndicator; } -ByteVector Frame::Header::render() const -{ - ByteVector flags(2, char(0)); // just blank for the moment +ByteVector Frame::Header::render() const { + ByteVector flags(2, char(0)); // just blank for the moment ByteVector v = d->frameID + - (d->version == 3 - ? ByteVector::fromUInt(d->frameSize) - : SynchData::fromUInt(d->frameSize)) + + (d->version == 3 ? ByteVector::fromUInt(d->frameSize) : SynchData::fromUInt(d->frameSize)) + flags; return v; } -bool Frame::Header::frameAlterPreservation() const -{ +bool Frame::Header::frameAlterPreservation() const { return fileAlterPreservation(); } diff --git a/3rdparty/taglib/mpeg/id3v2/id3v2frame.h b/3rdparty/taglib/mpeg/id3v2/id3v2frame.h index c5a5328a7..97304f547 100644 --- a/3rdparty/taglib/mpeg/id3v2/id3v2frame.h +++ b/3rdparty/taglib/mpeg/id3v2/id3v2frame.h @@ -33,17 +33,17 @@ namespace Strawberry_TagLib { namespace TagLib { - class StringList; - class PropertyMap; +class StringList; +class PropertyMap; - namespace ID3v2 { +namespace ID3v2 { - class Tag; - class FrameFactory; +class Tag; +class FrameFactory; - //! ID3v2 frame implementation +//! ID3v2 frame implementation - /*! +/*! * This class is the main ID3v2 frame implementation. In ID3v2, a tag is * split between a collection of frames (which are in turn split into fields * (Structure, 4) @@ -52,37 +52,35 @@ namespace TagLib { * specific to a given frame type is handed in one of the many subclasses. */ - class TAGLIB_EXPORT Frame - { - friend class Tag; - friend class FrameFactory; +class TAGLIB_EXPORT Frame { + friend class Tag; + friend class FrameFactory; - public: - - /*! + public: + /*! * Creates a textual frame which corresponds to a single key in the PropertyMap * interface. These are all (User)TextIdentificationFrames except TIPL and TMCL, * all (User)URLLinkFrames, CommentsFrames, and UnsynchronizedLyricsFrame. */ - static Frame *createTextualFrame(const String &key, const StringList &values); + static Frame *createTextualFrame(const String &key, const StringList &values); - /*! + /*! * Destroys this Frame instance. */ - virtual ~Frame(); + virtual ~Frame(); - /*! + /*! * Returns the Frame ID (Structure, 4) * (Frames, 4) */ - ByteVector frameID() const; + ByteVector frameID() const; - /*! + /*! * Returns the size of the frame. */ - unsigned int size() const; + unsigned int size() const; - /*! + /*! * Returns the size of the frame header * * \deprecated This is only accurate for ID3v2.3 or ID3v2.4. Please use @@ -90,25 +88,25 @@ namespace TagLib { * non-binary compatible release this will be made into a non-static * member that checks the internal ID3v2 version. */ - static unsigned int headerSize(); // BIC: make non-static + static unsigned int headerSize(); // BIC: make non-static - /*! + /*! * Returns the size of the frame header for the given ID3v2 version. * * \deprecated Please see the explanation above. */ - // BIC: remove - static unsigned int headerSize(unsigned int version); + // BIC: remove + static unsigned int headerSize(unsigned int version); - /*! + /*! * Sets the data that will be used as the frame. Since the length is not * known before the frame has been parsed, this should just be a pointer to * the first byte of the frame. It will determine the length internally * and make that available through size(). */ - void setData(const ByteVector &data); + void setData(const ByteVector &data); - /*! + /*! * Set the text of frame in the sanest way possible. This should only be * reimplemented in frames where there is some logical mapping to text. * @@ -117,176 +115,176 @@ namespace TagLib { * that frame's encoding. Please use the specific APIs of the frame types * to set the encoding if that is desired. */ - virtual void setText(const String &text); + virtual void setText(const String &text); - /*! + /*! * This returns the textual representation of the data in the frame. * Subclasses must reimplement this method to provide a string * representation of the frame's data. */ - virtual String toString() const = 0; + virtual String toString() const = 0; - /*! + /*! * Render the frame back to its binary format in a ByteVector. */ - ByteVector render() const; + ByteVector render() const; - /*! + /*! * Returns the text delimiter that is used between fields for the string * type \a t. */ - static ByteVector textDelimiter(String::Type t); + static ByteVector textDelimiter(String::Type t); - /*! + /*! * The string with which an instrument name is prefixed to build a key in a PropertyMap; * used to translate PropertyMaps to TMCL frames. In the current implementation, this * is "PERFORMER:". */ - static const String instrumentPrefix; - /*! + static const String instrumentPrefix; + /*! * The PropertyMap key prefix which triggers the use of a COMM frame instead of a TXXX * frame for a non-standard key. In the current implementation, this is "COMMENT:". */ - static const String commentPrefix; - /*! + static const String commentPrefix; + /*! * The PropertyMap key prefix which triggers the use of a USLT frame instead of a TXXX * frame for a non-standard key. In the current implementation, this is "LYRICS:". */ - static const String lyricsPrefix; - /*! + static const String lyricsPrefix; + /*! * The PropertyMap key prefix which triggers the use of a WXXX frame instead of a TXX * frame for a non-standard key. In the current implementation, this is "URL:". */ - static const String urlPrefix; + static const String urlPrefix; - protected: - class Header; + protected: + class Header; - /*! + /*! * Constructs an ID3v2 frame using \a data to read the header information. * All other processing of \a data should be handled in a subclass. * * \note This need not contain anything more than a frame ID, but * \e must contain at least that. */ - explicit Frame(const ByteVector &data); + explicit Frame(const ByteVector &data); - /*! + /*! * This creates an Frame using the header \a h. * * The ownership of this header will be assigned to the frame and the * header will be deleted when the frame is destroyed. */ - Frame(Header *h); + Frame(Header *h); - /*! + /*! * Returns a pointer to the frame header. */ - Header *header() const; + Header *header() const; - /*! + /*! * Sets the header to \a h. If \a deleteCurrent is true, this will free * the memory of the current header. * * The ownership of this header will be assigned to the frame and the * header will be deleted when the frame is destroyed. */ - void setHeader(Header *h, bool deleteCurrent = true); + void setHeader(Header *h, bool deleteCurrent = true); - /*! + /*! * Called by setData() to parse the frame data. It makes this information * available through the public API. */ - void parse(const ByteVector &data); + void parse(const ByteVector &data); - /*! + /*! * Called by parse() to parse the field data. It makes this information * available through the public API. This must be overridden by the * subclasses. */ - virtual void parseFields(const ByteVector &data) = 0; + virtual void parseFields(const ByteVector &data) = 0; - /*! + /*! * Render the field data back to a binary format in a ByteVector. This * must be overridden by subclasses. */ - virtual ByteVector renderFields() const = 0; + virtual ByteVector renderFields() const = 0; - /*! + /*! * Returns a ByteVector containing the field data given the frame data. * This correctly adjusts for the header size plus any additional frame * data that's specified in the frame header flags. */ - ByteVector fieldData(const ByteVector &frameData) const; + ByteVector fieldData(const ByteVector &frameData) const; - /*! + /*! * Reads a String of type \a encoding from the ByteVector \a data. If \a * position is passed in it is used both as the starting point and is * updated to return the position just after the string that has been read. * This is useful for reading strings sequentially. */ - String readStringField(const ByteVector &data, String::Type encoding, - int *position = 0); + String readStringField(const ByteVector &data, String::Type encoding, + int *position = 0); - /*! + /*! * Checks a the list of string values to see if they can be used with the * specified encoding and returns the recommended encoding. */ - // BIC: remove and make non-static - static String::Type checkEncoding(const StringList &fields, - String::Type encoding); + // BIC: remove and make non-static + static String::Type checkEncoding(const StringList &fields, + String::Type encoding); - /*! + /*! * Checks a the list of string values to see if they can be used with the * specified encoding and returns the recommended encoding. This method * also checks the ID3v2 version and makes sure the encoding can be used * in the specified version. */ - // BIC: remove and make non-static - static String::Type checkEncoding(const StringList &fields, - String::Type encoding, unsigned int version); + // BIC: remove and make non-static + static String::Type checkEncoding(const StringList &fields, + String::Type encoding, unsigned int version); - /*! + /*! * Checks a the list of string values to see if they can be used with the * specified encoding and returns the recommended encoding. This method * also checks the ID3v2 version and makes sure the encoding can be used * in the version specified by the frame's header. */ - String::Type checkTextEncoding(const StringList &fields, - String::Type encoding) const; + String::Type checkTextEncoding(const StringList &fields, + String::Type encoding) const; - /*! + /*! * Parses the contents of this frame as PropertyMap. If that fails, the returned * PropertyMap will be empty, and its unsupportedData() will contain this frame's * ID. * BIC: Will be a virtual function in future releases. */ - PropertyMap asProperties() const; + PropertyMap asProperties() const; - /*! + /*! * Returns an appropriate ID3 frame ID for the given free-form tag key. This method * will return an empty ByteVector if no specialized translation is found. */ - static ByteVector keyToFrameID(const String &); + static ByteVector keyToFrameID(const String &); - /*! + /*! * Returns a free-form tag name for the given ID3 frame ID. Note that this does not work * for general frame IDs such as TXXX or WXXX; in such a case an empty string is returned. */ - static String frameIDToKey(const ByteVector &); + static String frameIDToKey(const ByteVector &); - /*! + /*! * Returns an appropriate TXXX frame description for the given free-form tag key. */ - static String keyToTXXX(const String &); + static String keyToTXXX(const String &); - /*! + /*! * Returns a free-form tag name for the given ID3 frame description. */ - static String txxxToKey(const String &); + static String txxxToKey(const String &); - /*! + /*! * This helper function splits the PropertyMap \a original into three ProperytMaps * \a singleFrameProperties, \a tiplProperties, and \a tmclProperties, such that: * - \a singleFrameProperties contains only of keys which can be represented with @@ -299,21 +297,21 @@ namespace TagLib { * - \a tmclProperties contains the "musician credits" keys which should be mapped * to a TMCL frame */ - static void splitProperties(const PropertyMap &original, PropertyMap &singleFrameProperties, - PropertyMap &tiplProperties, PropertyMap &tmclProperties); + static void splitProperties(const PropertyMap &original, PropertyMap &singleFrameProperties, + PropertyMap &tiplProperties, PropertyMap &tmclProperties); - private: - Frame(const Frame &); - Frame &operator=(const Frame &); + private: + Frame(const Frame &); + Frame &operator=(const Frame &); - class FramePrivate; - friend class FramePrivate; - FramePrivate *d; - }; + class FramePrivate; + friend class FramePrivate; + FramePrivate *d; +}; - //! ID3v2 frame header implementation +//! ID3v2 frame header implementation - /*! +/*! * The ID3v2 Frame Header (Structure, 4) * * Every ID3v2::Frame has an associated header that gives some general @@ -325,10 +323,9 @@ namespace TagLib { * the type and attaches the header. */ - class TAGLIB_EXPORT Frame::Header - { - public: - /*! +class TAGLIB_EXPORT Frame::Header { + public: + /*! * Construct a Frame Header based on \a data. \a data must at least * contain a 4 byte frame ID, and optionally can contain flag data and the * frame size. i.e. Just the frame id -- "TALB" -- is a valid value. @@ -336,43 +333,43 @@ namespace TagLib { * \deprecated Please use the constructor below that accepts a version * number. */ - TAGLIB_DEPRECATED Header(const ByteVector &data, bool synchSafeInts); + TAGLIB_DEPRECATED Header(const ByteVector &data, bool synchSafeInts); - /*! + /*! * Construct a Frame Header based on \a data. \a data must at least * contain a 4 byte frame ID, and optionally can contain flag data and the * frame size. i.e. Just the frame id -- "TALB" -- is a valid value. * * \a version should be the ID3v2 version of the tag. */ - explicit Header(const ByteVector &data, unsigned int version = 4); + explicit Header(const ByteVector &data, unsigned int version = 4); - /*! + /*! * Destroys this Header instance. */ - virtual ~Header(); + virtual ~Header(); - /*! + /*! * Sets the data for the Header. * * \deprecated Please use the version below that accepts an ID3v2 version * number. */ - void setData(const ByteVector &data, bool synchSafeInts); + void setData(const ByteVector &data, bool synchSafeInts); - /*! + /*! * Sets the data for the Header. \a version should indicate the ID3v2 * version number of the tag that this frame is contained in. */ - void setData(const ByteVector &data, unsigned int version = 4); + void setData(const ByteVector &data, unsigned int version = 4); - /*! + /*! * Returns the Frame ID (Structure, 4) * (Frames, 4) */ - ByteVector frameID() const; + ByteVector frameID() const; - /*! + /*! * Sets the frame's ID to \a id. Only the first four bytes of \a id will * be used. * @@ -380,32 +377,32 @@ namespace TagLib { * provide a mechanism for transforming frames from a deprecated frame type * to a newer one -- i.e. TYER to TDRC from ID3v2.3 to ID3v2.4. */ - void setFrameID(const ByteVector &id); + void setFrameID(const ByteVector &id); - /*! + /*! * Returns the size of the frame data portion, as set when setData() was * called or set explicitly via setFrameSize(). */ - unsigned int frameSize() const; + unsigned int frameSize() const; - /*! + /*! * Sets the size of the frame data portion. */ - void setFrameSize(unsigned int size); + void setFrameSize(unsigned int size); - /*! + /*! * Returns the ID3v2 version of the header, as passed in from the * construction of the header or set via setVersion(). */ - unsigned int version() const; + unsigned int version() const; - /*! + /*! * Sets the ID3v2 version of the header, changing has impact on the * correct parsing/rendering of frame data. */ - void setVersion(unsigned int version); + void setVersion(unsigned int version); - /*! + /*! * Returns the size of the frame header in bytes. * * \deprecated Please use the version of this method that accepts a @@ -413,19 +410,19 @@ namespace TagLib { * removed in the next binary incompatible release (2.0) and will be * replaced with a non-static method that checks the frame version. */ - // BIC: make non-static - static unsigned int size(); + // BIC: make non-static + static unsigned int size(); - /*! + /*! * Returns the size of the frame header in bytes for the ID3v2 version * that's given. * * \deprecated Please see the explanation in the version above. */ - // BIC: remove - static unsigned int size(unsigned int version); + // BIC: remove + static unsigned int size(unsigned int version); - /*! + /*! * Returns true if the flag for tag alter preservation is set. * * The semantics are a little backwards from what would seem natural @@ -434,9 +431,9 @@ namespace TagLib { * * \see setTagAlterPreservation() */ - bool tagAlterPreservation() const; + bool tagAlterPreservation() const; - /*! + /*! * Sets the flag for preservation of this frame if the tag is set. If * this is set to true the frame will not be written when the tag is * saved. @@ -447,77 +444,77 @@ namespace TagLib { * * \see tagAlterPreservation() */ - void setTagAlterPreservation(bool discard); + void setTagAlterPreservation(bool discard); - /*! + /*! * Returns true if the flag for file alter preservation is set. * * \note This flag is currently ignored internally in TagLib. */ - bool fileAlterPreservation() const; + bool fileAlterPreservation() const; - /*! + /*! * Returns true if the frame is meant to be read only. * * \note This flag is currently ignored internally in TagLib. */ - bool readOnly() const; + bool readOnly() const; - /*! + /*! * Returns true if the flag for the grouping identity is set. * * \note This flag is currently ignored internally in TagLib. */ - bool groupingIdentity() const; + bool groupingIdentity() const; - /*! + /*! * Returns true if compression is enabled for this frame. * * \note This flag is currently ignored internally in TagLib. */ - bool compression() const; + bool compression() const; - /*! + /*! * Returns true if encryption is enabled for this frame. * * \note This flag is currently ignored internally in TagLib. */ - bool encryption() const; + bool encryption() const; #ifndef DO_NOT_DOCUMENT - bool unsycronisation() const; + bool unsycronisation() const; #endif - /*! + /*! * Returns true if unsynchronisation is enabled for this frame. */ - bool unsynchronisation() const; + bool unsynchronisation() const; - /*! + /*! * Returns true if the flag for a data length indicator is set. */ - bool dataLengthIndicator() const; + bool dataLengthIndicator() const; - /*! + /*! * Render the Header back to binary format in a ByteVector. */ - ByteVector render() const; + ByteVector render() const; - /*! + /*! * \deprecated */ - TAGLIB_DEPRECATED bool frameAlterPreservation() const; + TAGLIB_DEPRECATED bool frameAlterPreservation() const; - private: - Header(const Header &); - Header &operator=(const Header &); + private: + Header(const Header &); + Header &operator=(const Header &); - class HeaderPrivate; - HeaderPrivate *d; - }; + class HeaderPrivate; + HeaderPrivate *d; +}; - } -} -} +} // namespace ID3v2 +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/id3v2/id3v2framefactory.cpp b/3rdparty/taglib/mpeg/id3v2/id3v2framefactory.cpp index ff0f86051..3a6eb11d7 100644 --- a/3rdparty/taglib/mpeg/id3v2/id3v2framefactory.cpp +++ b/3rdparty/taglib/mpeg/id3v2/id3v2framefactory.cpp @@ -51,53 +51,48 @@ using namespace Strawberry_TagLib::TagLib; using namespace ID3v2; -namespace -{ - void updateGenre(TextIdentificationFrame *frame) - { - StringList fields = frame->fieldList(); - StringList newfields; +namespace { +void updateGenre(TextIdentificationFrame *frame) { + StringList fields = frame->fieldList(); + StringList newfields; - for(StringList::ConstIterator it = fields.begin(); it != fields.end(); ++it) { - String s = *it; - int end = s.find(")"); + for (StringList::ConstIterator it = fields.begin(); it != fields.end(); ++it) { + String s = *it; + int end = s.find(")"); - if(s.startsWith("(") && end > 0) { - // "(12)Genre" - String text = s.substr(end + 1); - bool ok; - int number = s.substr(1, end - 1).toInt(&ok); - if(ok && number >= 0 && number <= 255 && !(ID3v1::genre(number) == text)) - newfields.append(s.substr(1, end - 1)); - if(!text.isEmpty()) - newfields.append(text); - } - else { - // "Genre" or "12" - newfields.append(s); - } + if (s.startsWith("(") && end > 0) { + // "(12)Genre" + String text = s.substr(end + 1); + bool ok; + int number = s.substr(1, end - 1).toInt(&ok); + if (ok && number >= 0 && number <= 255 && !(ID3v1::genre(number) == text)) + newfields.append(s.substr(1, end - 1)); + if (!text.isEmpty()) + newfields.append(text); + } + else { + // "Genre" or "12" + newfields.append(s); } - - if(newfields.isEmpty()) - fields.append(String()); - - frame->setText(newfields); } -} -class FrameFactory::FrameFactoryPrivate -{ -public: - FrameFactoryPrivate() : - defaultEncoding(String::Latin1), - useDefaultEncoding(false) {} + if (newfields.isEmpty()) + fields.append(String()); + + frame->setText(newfields); +} +} // namespace + +class FrameFactory::FrameFactoryPrivate { + public: + FrameFactoryPrivate() : defaultEncoding(String::Latin1), + useDefaultEncoding(false) {} String::Type defaultEncoding; bool useDefaultEncoding; - template void setTextEncoding(T *frame) - { - if(useDefaultEncoding) + template void setTextEncoding(T *frame) { + if (useDefaultEncoding) frame->setTextEncoding(defaultEncoding); } }; @@ -108,30 +103,25 @@ FrameFactory FrameFactory::factory; // public members //////////////////////////////////////////////////////////////////////////////// -FrameFactory *FrameFactory::instance() -{ +FrameFactory *FrameFactory::instance() { return &factory; } -Frame *FrameFactory::createFrame(const ByteVector &data, bool synchSafeInts) const -{ +Frame *FrameFactory::createFrame(const ByteVector &data, bool synchSafeInts) const { return createFrame(data, static_cast(synchSafeInts ? 4 : 3)); } -Frame *FrameFactory::createFrame(const ByteVector &data, unsigned int version) const -{ +Frame *FrameFactory::createFrame(const ByteVector &data, unsigned int version) const { Header tagHeader; tagHeader.setMajorVersion(version); return createFrame(data, &tagHeader); } -Frame *FrameFactory::createFrame(const ByteVector &origData, Header *tagHeader) const -{ - return createFrame(origData, const_cast(tagHeader)); +Frame *FrameFactory::createFrame(const ByteVector &origData, Header *tagHeader) const { + return createFrame(origData, const_cast(tagHeader)); } -Frame *FrameFactory::createFrame(const ByteVector &origData, const Header *tagHeader) const -{ +Frame *FrameFactory::createFrame(const ByteVector &origData, const Header *tagHeader) const { ByteVector data = origData; unsigned int version = tagHeader->majorVersion(); Frame::Header *header = new Frame::Header(data, version); @@ -140,16 +130,15 @@ Frame *FrameFactory::createFrame(const ByteVector &origData, const Header *tagHe // A quick sanity check -- make sure that the frameID is 4 uppercase Latin1 // characters. Also make sure that there is data in the frame. - if(frameID.size() != (version < 3 ? 3 : 4) || - header->frameSize() <= static_cast(header->dataLengthIndicator() ? 4 : 0) || - header->frameSize() > data.size()) - { + if (frameID.size() != (version < 3 ? 3 : 4) || + header->frameSize() <= static_cast(header->dataLengthIndicator() ? 4 : 0) || + header->frameSize() > data.size()) { delete header; return nullptr; } #ifndef NO_ITUNES_HACKS - if(version == 3 && frameID.size() == 4 && frameID[3] == '\0') { + if (version == 3 && frameID.size() == 4 && frameID[3] == '\0') { // iTunes v2.3 tags store v2.2 frames - convert now frameID = frameID.mid(0, 3); header->setFrameID(frameID); @@ -159,14 +148,14 @@ Frame *FrameFactory::createFrame(const ByteVector &origData, const Header *tagHe } #endif - for(ByteVector::ConstIterator it = frameID.begin(); it != frameID.end(); it++) { - if( (*it < 'A' || *it > 'Z') && (*it < '0' || *it > '9') ) { + for (ByteVector::ConstIterator it = frameID.begin(); it != frameID.end(); it++) { + if ((*it < 'A' || *it > 'Z') && (*it < '0' || *it > '9')) { delete header; return nullptr; } } - if(version > 3 && (tagHeader->unsynchronisation() || header->unsynchronisation())) { + if (version > 3 && (tagHeader->unsynchronisation() || header->unsynchronisation())) { // Data lengths are not part of the encoded data, but since they are synch-safe // integers they will be never actually encoded. ByteVector frameData = data.mid(Frame::Header::size(version), header->frameSize()); @@ -177,17 +166,17 @@ Frame *FrameFactory::createFrame(const ByteVector &origData, const Header *tagHe // TagLib doesn't mess with encrypted frames, so just treat them // as unknown frames. - if(!zlib::isAvailable() && header->compression()) { + if (!zlib::isAvailable() && header->compression()) { debug("Compressed frames are currently not supported."); return new UnknownFrame(data, header); } - if(header->encryption()) { + if (header->encryption()) { debug("Encrypted frames are currently not supported."); return new UnknownFrame(data, header); } - if(!updateFrame(header)) { + if (!updateFrame(header)) { header->setTagAlterPreservation(true); return new UnknownFrame(data, header); } @@ -204,15 +193,13 @@ Frame *FrameFactory::createFrame(const ByteVector &origData, const Header *tagHe // Text Identification (frames 4.2) // Apple proprietary WFED (Podcast URL), MVNM (Movement Name), MVIN (Movement Number), GRP1 (Grouping) are in fact text frames. - if(frameID.startsWith("T") || frameID == "WFED" || frameID == "MVNM" || frameID == "MVIN" || frameID == "GRP1") { + if (frameID.startsWith("T") || frameID == "WFED" || frameID == "MVNM" || frameID == "MVIN" || frameID == "GRP1") { - TextIdentificationFrame *f = frameID != "TXXX" - ? new TextIdentificationFrame(data, header) - : new UserTextIdentificationFrame(data, header); + TextIdentificationFrame *f = frameID != "TXXX" ? new TextIdentificationFrame(data, header) : new UserTextIdentificationFrame(data, header); d->setTextEncoding(f); - if(frameID == "TCON") + if (frameID == "TCON") updateGenre(f); return f; @@ -220,7 +207,7 @@ Frame *FrameFactory::createFrame(const ByteVector &origData, const Header *tagHe // Comments (frames 4.10) - if(frameID == "COMM") { + if (frameID == "COMM") { CommentsFrame *f = new CommentsFrame(data, header); d->setTextEncoding(f); return f; @@ -228,7 +215,7 @@ Frame *FrameFactory::createFrame(const ByteVector &origData, const Header *tagHe // Attached Picture (frames 4.14) - if(frameID == "APIC") { + if (frameID == "APIC") { AttachedPictureFrame *f = new AttachedPictureFrame(data, header); d->setTextEncoding(f); return f; @@ -236,7 +223,7 @@ Frame *FrameFactory::createFrame(const ByteVector &origData, const Header *tagHe // ID3v2.2 Attached Picture - if(frameID == "PIC") { + if (frameID == "PIC") { AttachedPictureFrame *f = new AttachedPictureFrameV22(data, header); d->setTextEncoding(f); return f; @@ -244,17 +231,17 @@ Frame *FrameFactory::createFrame(const ByteVector &origData, const Header *tagHe // Relative Volume Adjustment (frames 4.11) - if(frameID == "RVA2") + if (frameID == "RVA2") return new RelativeVolumeFrame(data, header); // Unique File Identifier (frames 4.1) - if(frameID == "UFID") + if (frameID == "UFID") return new UniqueFileIdentifierFrame(data, header); // General Encapsulated Object (frames 4.15) - if(frameID == "GEOB") { + if (frameID == "GEOB") { GeneralEncapsulatedObjectFrame *f = new GeneralEncapsulatedObjectFrame(data, header); d->setTextEncoding(f); return f; @@ -262,8 +249,8 @@ Frame *FrameFactory::createFrame(const ByteVector &origData, const Header *tagHe // URL link (frames 4.3) - if(frameID.startsWith("W")) { - if(frameID != "WXXX") { + if (frameID.startsWith("W")) { + if (frameID != "WXXX") { return new UrlLinkFrame(data, header); } else { @@ -275,40 +262,40 @@ Frame *FrameFactory::createFrame(const ByteVector &origData, const Header *tagHe // Unsynchronized lyric/text transcription (frames 4.8) - if(frameID == "USLT") { + if (frameID == "USLT") { UnsynchronizedLyricsFrame *f = new UnsynchronizedLyricsFrame(data, header); - if(d->useDefaultEncoding) + if (d->useDefaultEncoding) f->setTextEncoding(d->defaultEncoding); return f; } // Synchronised lyrics/text (frames 4.9) - if(frameID == "SYLT") { + if (frameID == "SYLT") { SynchronizedLyricsFrame *f = new SynchronizedLyricsFrame(data, header); - if(d->useDefaultEncoding) + if (d->useDefaultEncoding) f->setTextEncoding(d->defaultEncoding); return f; } // Event timing codes (frames 4.5) - if(frameID == "ETCO") + if (frameID == "ETCO") return new EventTimingCodesFrame(data, header); // Popularimeter (frames 4.17) - if(frameID == "POPM") + if (frameID == "POPM") return new PopularimeterFrame(data, header); // Private (frames 4.27) - if(frameID == "PRIV") + if (frameID == "PRIV") return new PrivateFrame(data, header); // Ownership (frames 4.22) - if(frameID == "OWNE") { + if (frameID == "OWNE") { OwnershipFrame *f = new OwnershipFrame(data, header); d->setTextEncoding(f); return f; @@ -316,45 +303,42 @@ Frame *FrameFactory::createFrame(const ByteVector &origData, const Header *tagHe // Chapter (ID3v2 chapters 1.0) - if(frameID == "CHAP") + if (frameID == "CHAP") return new ChapterFrame(tagHeader, data, header); // Table of contents (ID3v2 chapters 1.0) - if(frameID == "CTOC") + if (frameID == "CTOC") return new TableOfContentsFrame(tagHeader, data, header); // Apple proprietary PCST (Podcast) - if(frameID == "PCST") + if (frameID == "PCST") return new PodcastFrame(data, header); return new UnknownFrame(data, header); } -void FrameFactory::rebuildAggregateFrames(ID3v2::Tag *tag) const -{ - if(tag->header()->majorVersion() < 4 && - tag->frameList("TDRC").size() == 1 && - tag->frameList("TDAT").size() == 1) - { +void FrameFactory::rebuildAggregateFrames(ID3v2::Tag *tag) const { + if (tag->header()->majorVersion() < 4 && + tag->frameList("TDRC").size() == 1 && + tag->frameList("TDAT").size() == 1) { TextIdentificationFrame *tdrc = dynamic_cast(tag->frameList("TDRC").front()); UnknownFrame *tdat = static_cast(tag->frameList("TDAT").front()); - if(tdrc && - tdrc->fieldList().size() == 1 && - tdrc->fieldList().front().size() == 4 && - tdat->data().size() >= 5) - { + if (tdrc && + tdrc->fieldList().size() == 1 && + tdrc->fieldList().front().size() == 4 && + tdat->data().size() >= 5) { String date(tdat->data().mid(1), String::Type(tdat->data()[0])); - if(date.length() == 4) { + if (date.length() == 4) { tdrc->setText(tdrc->toString() + '-' + date.substr(2, 2) + '-' + date.substr(0, 2)); - if(tag->frameList("TIME").size() == 1) { + if (tag->frameList("TIME").size() == 1) { UnknownFrame *timeframe = static_cast(tag->frameList("TIME").front()); - if(timeframe->data().size() >= 5) { + if (timeframe->data().size() >= 5) { String time(timeframe->data().mid(1), String::Type(timeframe->data()[0])); - if(time.length() == 4) { + if (time.length() == 4) { tdrc->setText(tdrc->toString() + 'T' + time.substr(0, 2) + ':' + time.substr(2, 2)); } } @@ -364,13 +348,11 @@ void FrameFactory::rebuildAggregateFrames(ID3v2::Tag *tag) const } } -String::Type FrameFactory::defaultTextEncoding() const -{ +String::Type FrameFactory::defaultTextEncoding() const { return d->defaultEncoding; } -void FrameFactory::setDefaultTextEncoding(String::Type encoding) -{ +void FrameFactory::setDefaultTextEncoding(String::Type encoding) { d->useDefaultEncoding = true; d->defaultEncoding = encoding; } @@ -379,171 +361,164 @@ void FrameFactory::setDefaultTextEncoding(String::Type encoding) // protected members //////////////////////////////////////////////////////////////////////////////// -FrameFactory::FrameFactory() : - d(new FrameFactoryPrivate()) -{ +FrameFactory::FrameFactory() : d(new FrameFactoryPrivate()) { } -FrameFactory::~FrameFactory() -{ +FrameFactory::~FrameFactory() { delete d; } -namespace -{ - // Frame conversion table ID3v2.2 -> 2.4 - const char *frameConversion2[][2] = { - { "BUF", "RBUF" }, - { "CNT", "PCNT" }, - { "COM", "COMM" }, - { "CRA", "AENC" }, - { "ETC", "ETCO" }, - { "GEO", "GEOB" }, - { "IPL", "TIPL" }, - { "MCI", "MCDI" }, - { "MLL", "MLLT" }, - { "POP", "POPM" }, - { "REV", "RVRB" }, - { "SLT", "SYLT" }, - { "STC", "SYTC" }, - { "TAL", "TALB" }, - { "TBP", "TBPM" }, - { "TCM", "TCOM" }, - { "TCO", "TCON" }, - { "TCP", "TCMP" }, - { "TCR", "TCOP" }, - { "TDY", "TDLY" }, - { "TEN", "TENC" }, - { "TFT", "TFLT" }, - { "TKE", "TKEY" }, - { "TLA", "TLAN" }, - { "TLE", "TLEN" }, - { "TMT", "TMED" }, - { "TOA", "TOAL" }, - { "TOF", "TOFN" }, - { "TOL", "TOLY" }, - { "TOR", "TDOR" }, - { "TOT", "TOAL" }, - { "TP1", "TPE1" }, - { "TP2", "TPE2" }, - { "TP3", "TPE3" }, - { "TP4", "TPE4" }, - { "TPA", "TPOS" }, - { "TPB", "TPUB" }, - { "TRC", "TSRC" }, - { "TRD", "TDRC" }, - { "TRK", "TRCK" }, - { "TS2", "TSO2" }, - { "TSA", "TSOA" }, - { "TSC", "TSOC" }, - { "TSP", "TSOP" }, - { "TSS", "TSSE" }, - { "TST", "TSOT" }, - { "TT1", "TIT1" }, - { "TT2", "TIT2" }, - { "TT3", "TIT3" }, - { "TXT", "TOLY" }, - { "TXX", "TXXX" }, - { "TYE", "TDRC" }, - { "UFI", "UFID" }, - { "ULT", "USLT" }, - { "WAF", "WOAF" }, - { "WAR", "WOAR" }, - { "WAS", "WOAS" }, - { "WCM", "WCOM" }, - { "WCP", "WCOP" }, - { "WPB", "WPUB" }, - { "WXX", "WXXX" }, +namespace { +// Frame conversion table ID3v2.2 -> 2.4 +const char *frameConversion2[][2] = { + { "BUF", "RBUF" }, + { "CNT", "PCNT" }, + { "COM", "COMM" }, + { "CRA", "AENC" }, + { "ETC", "ETCO" }, + { "GEO", "GEOB" }, + { "IPL", "TIPL" }, + { "MCI", "MCDI" }, + { "MLL", "MLLT" }, + { "POP", "POPM" }, + { "REV", "RVRB" }, + { "SLT", "SYLT" }, + { "STC", "SYTC" }, + { "TAL", "TALB" }, + { "TBP", "TBPM" }, + { "TCM", "TCOM" }, + { "TCO", "TCON" }, + { "TCP", "TCMP" }, + { "TCR", "TCOP" }, + { "TDY", "TDLY" }, + { "TEN", "TENC" }, + { "TFT", "TFLT" }, + { "TKE", "TKEY" }, + { "TLA", "TLAN" }, + { "TLE", "TLEN" }, + { "TMT", "TMED" }, + { "TOA", "TOAL" }, + { "TOF", "TOFN" }, + { "TOL", "TOLY" }, + { "TOR", "TDOR" }, + { "TOT", "TOAL" }, + { "TP1", "TPE1" }, + { "TP2", "TPE2" }, + { "TP3", "TPE3" }, + { "TP4", "TPE4" }, + { "TPA", "TPOS" }, + { "TPB", "TPUB" }, + { "TRC", "TSRC" }, + { "TRD", "TDRC" }, + { "TRK", "TRCK" }, + { "TS2", "TSO2" }, + { "TSA", "TSOA" }, + { "TSC", "TSOC" }, + { "TSP", "TSOP" }, + { "TSS", "TSSE" }, + { "TST", "TSOT" }, + { "TT1", "TIT1" }, + { "TT2", "TIT2" }, + { "TT3", "TIT3" }, + { "TXT", "TOLY" }, + { "TXX", "TXXX" }, + { "TYE", "TDRC" }, + { "UFI", "UFID" }, + { "ULT", "USLT" }, + { "WAF", "WOAF" }, + { "WAR", "WOAR" }, + { "WAS", "WOAS" }, + { "WCM", "WCOM" }, + { "WCP", "WCOP" }, + { "WPB", "WPUB" }, + { "WXX", "WXXX" }, - // Apple iTunes nonstandard frames - { "PCS", "PCST" }, - { "TCT", "TCAT" }, - { "TDR", "TDRL" }, - { "TDS", "TDES" }, - { "TID", "TGID" }, - { "WFD", "WFED" }, - { "MVN", "MVNM" }, - { "MVI", "MVIN" }, - { "GP1", "GRP1" }, - }; - const size_t frameConversion2Size = sizeof(frameConversion2) / sizeof(frameConversion2[0]); + // Apple iTunes nonstandard frames + { "PCS", "PCST" }, + { "TCT", "TCAT" }, + { "TDR", "TDRL" }, + { "TDS", "TDES" }, + { "TID", "TGID" }, + { "WFD", "WFED" }, + { "MVN", "MVNM" }, + { "MVI", "MVIN" }, + { "GP1", "GRP1" }, +}; +const size_t frameConversion2Size = sizeof(frameConversion2) / sizeof(frameConversion2[0]); - // Frame conversion table ID3v2.3 -> 2.4 - const char *frameConversion3[][2] = { - { "TORY", "TDOR" }, - { "TYER", "TDRC" }, - { "IPLS", "TIPL" }, - }; - const size_t frameConversion3Size = sizeof(frameConversion3) / sizeof(frameConversion3[0]); -} +// Frame conversion table ID3v2.3 -> 2.4 +const char *frameConversion3[][2] = { + { "TORY", "TDOR" }, + { "TYER", "TDRC" }, + { "IPLS", "TIPL" }, +}; +const size_t frameConversion3Size = sizeof(frameConversion3) / sizeof(frameConversion3[0]); +} // namespace -bool FrameFactory::updateFrame(Frame::Header *header) const -{ +bool FrameFactory::updateFrame(Frame::Header *header) const { const ByteVector frameID = header->frameID(); - switch(header->version()) { + switch (header->version()) { - case 2: // ID3v2.2 - { - if(frameID == "CRM" || - frameID == "EQU" || - frameID == "LNK" || - frameID == "RVA" || - frameID == "TIM" || - frameID == "TSI" || - frameID == "TDA") + case 2: // ID3v2.2 { - debug("ID3v2.4 no longer supports the frame type " + String(frameID) + - ". It will be discarded from the tag."); - return false; - } - - // ID3v2.2 only used 3 bytes for the frame ID, so we need to convert all of - // the frames to their 4 byte ID3v2.4 equivalent. - - for(size_t i = 0; i < frameConversion2Size; ++i) { - if(frameID == frameConversion2[i][0]) { - header->setFrameID(frameConversion2[i][1]); - break; + if (frameID == "CRM" || + frameID == "EQU" || + frameID == "LNK" || + frameID == "RVA" || + frameID == "TIM" || + frameID == "TSI" || + frameID == "TDA") { + debug("ID3v2.4 no longer supports the frame type " + String(frameID) + + ". It will be discarded from the tag."); + return false; } + + // ID3v2.2 only used 3 bytes for the frame ID, so we need to convert all of + // the frames to their 4 byte ID3v2.4 equivalent. + + for (size_t i = 0; i < frameConversion2Size; ++i) { + if (frameID == frameConversion2[i][0]) { + header->setFrameID(frameConversion2[i][1]); + break; + } + } + + break; } - break; - } - - case 3: // ID3v2.3 - { - if(frameID == "EQUA" || - frameID == "RVAD" || - frameID == "TIME" || - frameID == "TRDA" || - frameID == "TSIZ" || - frameID == "TDAT") + case 3: // ID3v2.3 { - debug("ID3v2.4 no longer supports the frame type " + String(frameID) + - ". It will be discarded from the tag."); - return false; - } - - for(size_t i = 0; i < frameConversion3Size; ++i) { - if(frameID == frameConversion3[i][0]) { - header->setFrameID(frameConversion3[i][1]); - break; + if (frameID == "EQUA" || + frameID == "RVAD" || + frameID == "TIME" || + frameID == "TRDA" || + frameID == "TSIZ" || + frameID == "TDAT") { + debug("ID3v2.4 no longer supports the frame type " + String(frameID) + + ". It will be discarded from the tag."); + return false; } + + for (size_t i = 0; i < frameConversion3Size; ++i) { + if (frameID == frameConversion3[i][0]) { + header->setFrameID(frameConversion3[i][1]); + break; + } + } + + break; } - break; - } + default: - default: + // This should catch a typo that existed in TagLib up to and including + // version 1.1 where TRDC was used for the year rather than TDRC. - // This should catch a typo that existed in TagLib up to and including - // version 1.1 where TRDC was used for the year rather than TDRC. + if (frameID == "TRDC") + header->setFrameID("TDRC"); - if(frameID == "TRDC") - header->setFrameID("TDRC"); - - break; + break; } return true; diff --git a/3rdparty/taglib/mpeg/id3v2/id3v2framefactory.h b/3rdparty/taglib/mpeg/id3v2/id3v2framefactory.h index 22dfe82e9..82df9055a 100644 --- a/3rdparty/taglib/mpeg/id3v2/id3v2framefactory.h +++ b/3rdparty/taglib/mpeg/id3v2/id3v2framefactory.h @@ -1,4 +1,4 @@ - /*************************************************************************** +/*************************************************************************** copyright : (C) 2002 - 2008 by Scott Wheeler email : wheeler@kde.org ***************************************************************************/ @@ -34,13 +34,13 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace ID3v2 { +namespace ID3v2 { - class TextIdentificationFrame; +class TextIdentificationFrame; - //! A factory for creating ID3v2 frames during parsing +//! A factory for creating ID3v2 frames during parsing - /*! +/*! * This factory abstracts away the frame creation process and instantiates * the appropriate ID3v2::Frame subclasses based on the contents of the * data. @@ -63,11 +63,10 @@ namespace TagLib { * \see ID3v2::Tag::addFrame() */ - class TAGLIB_EXPORT FrameFactory - { - public: - static FrameFactory *instance(); - /*! +class TAGLIB_EXPORT FrameFactory { + public: + static FrameFactory *instance(); + /*! * Create a frame based on \a data. \a synchSafeInts should only be set * false if we are parsing an old tag (v2.3 or older) that does not support * synchsafe ints. @@ -75,9 +74,9 @@ namespace TagLib { * \deprecated Please use the method below that accepts a ID3v2::Header * instance in new code. */ - Frame *createFrame(const ByteVector &data, bool synchSafeInts) const; + Frame *createFrame(const ByteVector &data, bool synchSafeInts) const; - /*! + /*! * Create a frame based on \a data. \a version should indicate the ID3v2 * version of the tag. As ID3v2.4 is the most current version of the * standard 4 is the default. @@ -85,29 +84,29 @@ namespace TagLib { * \deprecated Please use the method below that accepts a ID3v2::Header * instance in new code. */ - Frame *createFrame(const ByteVector &data, unsigned int version = 4) const; + Frame *createFrame(const ByteVector &data, unsigned int version = 4) const; - /*! + /*! * \deprecated */ - // BIC: remove - Frame *createFrame(const ByteVector &data, Header *tagHeader) const; - /*! + // BIC: remove + Frame *createFrame(const ByteVector &data, Header *tagHeader) const; + /*! * Create a frame based on \a data. \a tagHeader should be a valid * ID3v2::Header instance. */ - // BIC: make virtual - Frame *createFrame(const ByteVector &data, const Header *tagHeader) const; + // BIC: make virtual + Frame *createFrame(const ByteVector &data, const Header *tagHeader) const; - /*! + /*! * After a tag has been read, this tries to rebuild some of them * information, most notably the recording date, from frames that * have been deprecated and can't be upgraded directly. */ - // BIC: Make virtual - void rebuildAggregateFrames(ID3v2::Tag *tag) const; + // BIC: Make virtual + void rebuildAggregateFrames(ID3v2::Tag *tag) const; - /*! + /*! * Returns the default text encoding for text frames. If setTextEncoding() * has not been explicitly called this will only be used for new text * frames. However, if this value has been set explicitly all frames will be @@ -116,9 +115,9 @@ namespace TagLib { * * \see setDefaultTextEncoding() */ - String::Type defaultTextEncoding() const; + String::Type defaultTextEncoding() const; - /*! + /*! * Set the default text encoding for all text frames that are created to * \a encoding. If no value is set the frames with either default to the * encoding type that was parsed and new frames default to Latin1. @@ -127,21 +126,21 @@ namespace TagLib { * * \see defaultTextEncoding() */ - void setDefaultTextEncoding(String::Type encoding); + void setDefaultTextEncoding(String::Type encoding); - protected: - /*! + protected: + /*! * Constructs a frame factory. Because this is a singleton this method is * protected, but may be used for subclasses. */ - FrameFactory(); + FrameFactory(); - /*! + /*! * Destroys the frame factory. */ - virtual ~FrameFactory(); + virtual ~FrameFactory(); - /*! + /*! * This method checks for compliance to the current ID3v2 standard (2.4) * and does nothing in the common case. However if a frame is found that * is not compatible with the current standard, this method either updates @@ -152,20 +151,20 @@ namespace TagLib { * * See the id3v2.4.0-changes.txt document for further information. */ - virtual bool updateFrame(Frame::Header *header) const; + virtual bool updateFrame(Frame::Header *header) const; - private: - FrameFactory(const FrameFactory &); - FrameFactory &operator=(const FrameFactory &); + private: + FrameFactory(const FrameFactory &); + FrameFactory &operator=(const FrameFactory &); - static FrameFactory factory; + static FrameFactory factory; - class FrameFactoryPrivate; - FrameFactoryPrivate *d; - }; + class FrameFactoryPrivate; + FrameFactoryPrivate *d; +}; - } -} -} +} // namespace ID3v2 +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/id3v2/id3v2header.cpp b/3rdparty/taglib/mpeg/id3v2/id3v2header.cpp index 0396734fc..e95d1455b 100644 --- a/3rdparty/taglib/mpeg/id3v2/id3v2header.cpp +++ b/3rdparty/taglib/mpeg/id3v2/id3v2header.cpp @@ -36,17 +36,15 @@ using namespace Strawberry_TagLib::TagLib; using namespace ID3v2; -class Header::HeaderPrivate -{ -public: - HeaderPrivate() : - majorVersion(4), - revisionNumber(0), - unsynchronisation(false), - extendedHeader(false), - experimentalIndicator(false), - footerPresent(false), - tagSize(0) {} +class Header::HeaderPrivate { + public: + HeaderPrivate() : majorVersion(4), + revisionNumber(0), + unsynchronisation(false), + extendedHeader(false), + experimentalIndicator(false), + footerPresent(false), + tagSize(0) {} unsigned int majorVersion; unsigned int revisionNumber; @@ -63,13 +61,11 @@ public: // static members //////////////////////////////////////////////////////////////////////////////// -unsigned int Header::size() -{ +unsigned int Header::size() { return 10; } -ByteVector Header::fileIdentifier() -{ +ByteVector Header::fileIdentifier() { return ByteVector::fromCString("ID3"); } @@ -77,82 +73,65 @@ ByteVector Header::fileIdentifier() // public members //////////////////////////////////////////////////////////////////////////////// -Header::Header() : - d(new HeaderPrivate()) -{ +Header::Header() : d(new HeaderPrivate()) { } -Header::Header(const ByteVector &data) : - d(new HeaderPrivate()) -{ +Header::Header(const ByteVector &data) : d(new HeaderPrivate()) { parse(data); } -Header::~Header() -{ +Header::~Header() { delete d; } -unsigned int Header::majorVersion() const -{ +unsigned int Header::majorVersion() const { return d->majorVersion; } -void Header::setMajorVersion(unsigned int version) -{ +void Header::setMajorVersion(unsigned int version) { d->majorVersion = version; } -unsigned int Header::revisionNumber() const -{ +unsigned int Header::revisionNumber() const { return d->revisionNumber; } -bool Header::unsynchronisation() const -{ +bool Header::unsynchronisation() const { return d->unsynchronisation; } -bool Header::extendedHeader() const -{ +bool Header::extendedHeader() const { return d->extendedHeader; } -bool Header::experimentalIndicator() const -{ +bool Header::experimentalIndicator() const { return d->experimentalIndicator; } -bool Header::footerPresent() const -{ +bool Header::footerPresent() const { return d->footerPresent; } -unsigned int Header::tagSize() const -{ +unsigned int Header::tagSize() const { return d->tagSize; } -unsigned int Header::completeTagSize() const -{ - if(d->footerPresent) +unsigned int Header::completeTagSize() const { + if (d->footerPresent) return d->tagSize + size() + Footer::size(); else return d->tagSize + size(); } -void Header::setTagSize(unsigned int s) -{ +void Header::setTagSize(unsigned int s) { d->tagSize = s; } -void Header::setData(const ByteVector &data) -{ +void Header::setData(const ByteVector &data) { parse(data); } -ByteVector Header::render() const -{ +ByteVector Header::render() const { ByteVector v; // add the file identifier -- "ID3" @@ -191,9 +170,8 @@ ByteVector Header::render() const // protected members //////////////////////////////////////////////////////////////////////////////// -void Header::parse(const ByteVector &data) -{ - if(data.size() < size()) +void Header::parse(const ByteVector &data) { + if (data.size() < size()) return; // do some sanity checking -- even in ID3v2.3.0 and less the tag size is a @@ -205,14 +183,14 @@ void Header::parse(const ByteVector &data) ByteVector sizeData = data.mid(6, 4); - if(sizeData.size() != 4) { + if (sizeData.size() != 4) { d->tagSize = 0; debug("TagLib::ID3v2::Header::parse() - The tag size as read was 0 bytes!"); return; } - for(ByteVector::ConstIterator it = sizeData.begin(); it != sizeData.end(); it++) { - if(static_cast(*it) >= 128) { + for (ByteVector::ConstIterator it = sizeData.begin(); it != sizeData.end(); it++) { + if (static_cast(*it) >= 128) { d->tagSize = 0; debug("TagLib::ID3v2::Header::parse() - One of the size bytes in the id3v2 header was greater than the allowed 128."); return; @@ -222,18 +200,18 @@ void Header::parse(const ByteVector &data) // The first three bytes, data[0..2], are the File Identifier, "ID3". (structure 3.1 "file identifier") // Read the version number from the fourth and fifth bytes. - d->majorVersion = data[3]; // (structure 3.1 "major version") - d->revisionNumber = data[4]; // (structure 3.1 "revision number") + d->majorVersion = data[3]; // (structure 3.1 "major version") + d->revisionNumber = data[4]; // (structure 3.1 "revision number") // Read the flags, the first four bits of the sixth byte. std::bitset<8> flags(data[5]); - d->unsynchronisation = flags[7]; // (structure 3.1.a) - d->extendedHeader = flags[6]; // (structure 3.1.b) - d->experimentalIndicator = flags[5]; // (structure 3.1.c) - d->footerPresent = flags[4]; // (structure 3.1.d) + d->unsynchronisation = flags[7]; // (structure 3.1.a) + d->extendedHeader = flags[6]; // (structure 3.1.b) + d->experimentalIndicator = flags[5]; // (structure 3.1.c) + d->footerPresent = flags[4]; // (structure 3.1.d) // Get the size from the remaining four bytes (read above) - d->tagSize = SynchData::toUInt(sizeData); // (structure 3.1 "size") + d->tagSize = SynchData::toUInt(sizeData); // (structure 3.1 "size") } diff --git a/3rdparty/taglib/mpeg/id3v2/id3v2header.h b/3rdparty/taglib/mpeg/id3v2/id3v2header.h index 5cce280d8..4a6d37f46 100644 --- a/3rdparty/taglib/mpeg/id3v2/id3v2header.h +++ b/3rdparty/taglib/mpeg/id3v2/id3v2header.h @@ -33,11 +33,11 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace ID3v2 { +namespace ID3v2 { - //! An implementation of ID3v2 headers +//! An implementation of ID3v2 headers - /*! +/*! * This class implements ID3v2 headers. It attempts to follow, both * semantically and programmatically, the structure specified in * the ID3v2 standard. The API is based on the properties of ID3v2 headers @@ -46,32 +46,31 @@ namespace TagLib { * (Structure, 3.1) */ - class TAGLIB_EXPORT Header - { - public: - /*! +class TAGLIB_EXPORT Header { + public: + /*! * Constructs an empty ID3v2 header. */ - Header(); + Header(); - /*! + /*! * Constructs an ID3v2 header based on \a data. parse() is called * immediately. */ - Header(const ByteVector &data); + Header(const ByteVector &data); - /*! + /*! * Destroys the header. */ - virtual ~Header(); + virtual ~Header(); - /*! + /*! * Returns the major version number. (Note: This is the 4, not the 2 in * ID3v2.4.0. The 2 is implied.) */ - unsigned int majorVersion() const; + unsigned int majorVersion() const; - /*! + /*! * Set the the major version number to \a version. (Note: This is * the 4, not the 2 in ID3v2.4.0. The 2 is implied.) * \see majorVersion() @@ -80,34 +79,34 @@ namespace TagLib { * version which is written and in general should not be called by API * users. */ - void setMajorVersion(unsigned int version); + void setMajorVersion(unsigned int version); - /*! + /*! * Returns the revision number. (Note: This is the 0, not the 4 in * ID3v2.4.0. The 2 is implied.) */ - unsigned int revisionNumber() const; + unsigned int revisionNumber() const; - /*! + /*! * Returns true if unsynchronisation has been applied to all frames. */ - bool unsynchronisation() const; + bool unsynchronisation() const; - /*! + /*! * Returns true if an extended header is present in the tag. */ - bool extendedHeader() const; + bool extendedHeader() const; - /*! + /*! * Returns true if the experimental indicator flag is set. */ - bool experimentalIndicator() const; + bool experimentalIndicator() const; - /*! + /*! * Returns true if a footer is present in the tag. */ - bool footerPresent() const; - /*! + bool footerPresent() const; + /*! * Returns the tag size in bytes. This is the size of the frame content. * The size of the \e entire tag will be this plus the header size (10 * bytes) and, if present, the footer size (potentially another 10 bytes). @@ -118,61 +117,61 @@ namespace TagLib { * * \see completeTagSize() */ - unsigned int tagSize() const; + unsigned int tagSize() const; - /*! + /*! * Returns the tag size, including the header and, if present, the footer * size. * * \see tagSize() */ - unsigned int completeTagSize() const; + unsigned int completeTagSize() const; - /*! + /*! * Set the tag size to \a s. * \see tagSize() */ - void setTagSize(unsigned int s); + void setTagSize(unsigned int s); - /*! + /*! * Returns the size of the header. Presently this is always 10 bytes. */ - static unsigned int size(); + static unsigned int size(); - /*! + /*! * Returns the string used to identify and ID3v2 tag inside of a file. * Presently this is always "ID3". */ - static ByteVector fileIdentifier(); + static ByteVector fileIdentifier(); - /*! + /*! * Sets the data that will be used as the header. 10 bytes, starting from * the beginning of \a data are used. */ - void setData(const ByteVector &data); + void setData(const ByteVector &data); - /*! + /*! * Renders the Header back to binary format. */ - ByteVector render() const; + ByteVector render() const; - protected: - /*! + protected: + /*! * Called by setData() to parse the header data. It makes this information * available through the public API. */ - void parse(const ByteVector &data); + void parse(const ByteVector &data); - private: - Header(const Header &); - Header &operator=(const Header &); + private: + Header(const Header &); + Header &operator=(const Header &); - class HeaderPrivate; - HeaderPrivate *d; - }; + class HeaderPrivate; + HeaderPrivate *d; +}; - } -} -} +} // namespace ID3v2 +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/id3v2/id3v2synchdata.cpp b/3rdparty/taglib/mpeg/id3v2/id3v2synchdata.cpp index 10e0e38f1..55128c895 100644 --- a/3rdparty/taglib/mpeg/id3v2/id3v2synchdata.cpp +++ b/3rdparty/taglib/mpeg/id3v2/id3v2synchdata.cpp @@ -30,14 +30,13 @@ using namespace Strawberry_TagLib::TagLib; using namespace ID3v2; -unsigned int SynchData::toUInt(const ByteVector &data) -{ +unsigned int SynchData::toUInt(const ByteVector &data) { unsigned int sum = 0; bool notSynchSafe = false; int last = data.size() > 4 ? 3 : data.size() - 1; - for(int i = 0; i <= last; i++) { - if(data[i] & 0x80) { + for (int i = 0; i <= last; i++) { + if (data[i] & 0x80) { notSynchSafe = true; break; } @@ -45,11 +44,11 @@ unsigned int SynchData::toUInt(const ByteVector &data) sum |= (data[i] & 0x7f) << ((last - i) * 7); } - if(notSynchSafe) { + if (notSynchSafe) { // Invalid data; assume this was created by some buggy software that just // put normal integers here rather than syncsafe ones, and try it that // way. - if(data.size() >= 4) { + if (data.size() >= 4) { sum = data.toUInt(0, true); } else { @@ -62,18 +61,16 @@ unsigned int SynchData::toUInt(const ByteVector &data) return sum; } -ByteVector SynchData::fromUInt(unsigned int value) -{ +ByteVector SynchData::fromUInt(unsigned int value) { ByteVector v(4, 0); - for(int i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) v[i] = static_cast(value >> ((3 - i) * 7) & 0x7f); return v; } -ByteVector SynchData::decode(const ByteVector &data) -{ +ByteVector SynchData::decode(const ByteVector &data) { // We have this optimized method instead of using ByteVector::replace(), // since it makes a great difference when decoding huge unsynchronized frames. @@ -82,14 +79,14 @@ ByteVector SynchData::decode(const ByteVector &data) ByteVector::ConstIterator src = data.begin(); ByteVector::Iterator dst = result.begin(); - while(src < data.end() - 1) { + while (src < data.end() - 1) { *dst++ = *src++; - if(*(src - 1) == '\xff' && *src == '\x00') + if (*(src - 1) == '\xff' && *src == '\x00') src++; } - if(src < data.end()) + if (src < data.end()) *dst++ = *src++; result.resize(static_cast(dst - result.begin())); diff --git a/3rdparty/taglib/mpeg/id3v2/id3v2synchdata.h b/3rdparty/taglib/mpeg/id3v2/id3v2synchdata.h index 87f4b1c5a..f70451ebf 100644 --- a/3rdparty/taglib/mpeg/id3v2/id3v2synchdata.h +++ b/3rdparty/taglib/mpeg/id3v2/id3v2synchdata.h @@ -32,11 +32,11 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace ID3v2 { +namespace ID3v2 { - //! A few functions for ID3v2 synch safe integer conversion +//! A few functions for ID3v2 synch safe integer conversion - /*! +/*! * In the ID3v2.4 standard most integer values are encoded as "synch safe" * integers which are encoded in such a way that they will not give false * MPEG syncs and confuse MPEG decoders. This namespace provides some @@ -44,29 +44,28 @@ namespace TagLib { * things rendering and parsing ID3v2 data. */ - namespace SynchData - { - /*! +namespace SynchData { +/*! * This returns the unsigned integer value of \a data where \a data is a * ByteVector that contains a \e synchsafe integer (Structure, * 6.2). The default \a length of * 4 is used if another value is not specified. */ - TAGLIB_EXPORT unsigned int toUInt(const ByteVector &data); +TAGLIB_EXPORT unsigned int toUInt(const ByteVector &data); - /*! +/*! * Returns a 4 byte (32 bit) synchsafe integer based on \a value. */ - TAGLIB_EXPORT ByteVector fromUInt(unsigned int value); +TAGLIB_EXPORT ByteVector fromUInt(unsigned int value); - /*! +/*! * Convert the data from unsynchronized data to its original format. */ - TAGLIB_EXPORT ByteVector decode(const ByteVector &input); - } +TAGLIB_EXPORT ByteVector decode(const ByteVector &input); +} // namespace SynchData - } -} -} +} // namespace ID3v2 +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/id3v2/id3v2tag.cpp b/3rdparty/taglib/mpeg/id3v2/id3v2tag.cpp index 5e2f2f92c..468562ba5 100644 --- a/3rdparty/taglib/mpeg/id3v2/id3v2tag.cpp +++ b/3rdparty/taglib/mpeg/id3v2/id3v2tag.cpp @@ -47,30 +47,25 @@ using namespace Strawberry_TagLib::TagLib; using namespace ID3v2; -namespace -{ - const ID3v2::Latin1StringHandler defaultStringHandler; - const ID3v2::Latin1StringHandler *stringHandler = &defaultStringHandler; +namespace { +const ID3v2::Latin1StringHandler defaultStringHandler; +const ID3v2::Latin1StringHandler *stringHandler = &defaultStringHandler; - const long MinPaddingSize = 1024; - const long MaxPaddingSize = 1024 * 1024; -} +const long MinPaddingSize = 1024; +const long MaxPaddingSize = 1024 * 1024; +} // namespace -class ID3v2::Tag::TagPrivate -{ -public: - TagPrivate() : - factory(0), - file(0), - tagOffset(0), - extendedHeader(0), - footer(0) - { +class ID3v2::Tag::TagPrivate { + public: + TagPrivate() : factory(0), + file(0), + tagOffset(0), + extendedHeader(0), + footer(0) { frameList.setAutoDelete(true); } - ~TagPrivate() - { + ~TagPrivate() { delete extendedHeader; delete footer; } @@ -92,16 +87,13 @@ public: // StringHandler implementation //////////////////////////////////////////////////////////////////////////////// -Latin1StringHandler::Latin1StringHandler() -{ +Latin1StringHandler::Latin1StringHandler() { } -Latin1StringHandler::~Latin1StringHandler() -{ +Latin1StringHandler::~Latin1StringHandler() { } -String Latin1StringHandler::parse(const ByteVector &data) const -{ +String Latin1StringHandler::parse(const ByteVector &data) const { return String(data, String::Latin1); } @@ -109,17 +101,13 @@ String Latin1StringHandler::parse(const ByteVector &data) const // public members //////////////////////////////////////////////////////////////////////////////// -ID3v2::Tag::Tag() : - Strawberry_TagLib::TagLib::Tag(), - d(new TagPrivate()) -{ +ID3v2::Tag::Tag() : Strawberry_TagLib::TagLib::Tag(), + d(new TagPrivate()) { d->factory = FrameFactory::instance(); } -ID3v2::Tag::Tag(File *file, long tagOffset, const FrameFactory *factory) : - Strawberry_TagLib::TagLib::Tag(), - d(new TagPrivate()) -{ +ID3v2::Tag::Tag(File *file, long tagOffset, const FrameFactory *factory) : Strawberry_TagLib::TagLib::Tag(), + d(new TagPrivate()) { d->factory = factory; d->file = file; d->tagOffset = tagOffset; @@ -127,59 +115,51 @@ ID3v2::Tag::Tag(File *file, long tagOffset, const FrameFactory *factory) : read(); } -ID3v2::Tag::~Tag() -{ +ID3v2::Tag::~Tag() { delete d; } -String ID3v2::Tag::title() const -{ - if(!d->frameListMap["TIT2"].isEmpty()) +String ID3v2::Tag::title() const { + if (!d->frameListMap["TIT2"].isEmpty()) return d->frameListMap["TIT2"].front()->toString(); return String(); } -String ID3v2::Tag::artist() const -{ - if(!d->frameListMap["TPE1"].isEmpty()) +String ID3v2::Tag::artist() const { + if (!d->frameListMap["TPE1"].isEmpty()) return d->frameListMap["TPE1"].front()->toString(); return String(); } -String ID3v2::Tag::album() const -{ - if(!d->frameListMap["TALB"].isEmpty()) +String ID3v2::Tag::album() const { + if (!d->frameListMap["TALB"].isEmpty()) return d->frameListMap["TALB"].front()->toString(); return String(); } -String ID3v2::Tag::comment() const -{ +String ID3v2::Tag::comment() const { const FrameList &comments = d->frameListMap["COMM"]; - if(comments.isEmpty()) + if (comments.isEmpty()) return String(); - for(FrameList::ConstIterator it = comments.begin(); it != comments.end(); ++it) - { + for (FrameList::ConstIterator it = comments.begin(); it != comments.end(); ++it) { CommentsFrame *frame = dynamic_cast(*it); - if(frame && frame->description().isEmpty()) + if (frame && frame->description().isEmpty()) return (*it)->toString(); } return comments.front()->toString(); } -String ID3v2::Tag::genre() const -{ +String ID3v2::Tag::genre() const { // TODO: In the next major version (TagLib 2.0) a list of multiple genres // should be separated by " / " instead of " ". For the moment to keep // the behavior the same as released versions it is being left with " ". - if(d->frameListMap["TCON"].isEmpty() || - !dynamic_cast(d->frameListMap["TCON"].front())) - { + if (d->frameListMap["TCON"].isEmpty() || + !dynamic_cast(d->frameListMap["TCON"].front())) { return String(); } @@ -196,61 +176,55 @@ String ID3v2::Tag::genre() const StringList genres; - for(StringList::Iterator it = fields.begin(); it != fields.end(); ++it) { + for (StringList::Iterator it = fields.begin(); it != fields.end(); ++it) { - if((*it).isEmpty()) + if ((*it).isEmpty()) continue; bool ok; int number = (*it).toInt(&ok); - if(ok && number >= 0 && number <= 255) { + if (ok && number >= 0 && number <= 255) { *it = ID3v1::genre(number); } - if(std::find(genres.begin(), genres.end(), *it) == genres.end()) + if (std::find(genres.begin(), genres.end(), *it) == genres.end()) genres.append(*it); } return genres.toString(); } -unsigned int ID3v2::Tag::year() const -{ - if(!d->frameListMap["TDRC"].isEmpty()) +unsigned int ID3v2::Tag::year() const { + if (!d->frameListMap["TDRC"].isEmpty()) return d->frameListMap["TDRC"].front()->toString().substr(0, 4).toInt(); return 0; } -unsigned int ID3v2::Tag::track() const -{ - if(!d->frameListMap["TRCK"].isEmpty()) +unsigned int ID3v2::Tag::track() const { + if (!d->frameListMap["TRCK"].isEmpty()) return d->frameListMap["TRCK"].front()->toString().toInt(); return 0; } -void ID3v2::Tag::setTitle(const String &s) -{ +void ID3v2::Tag::setTitle(const String &s) { setTextFrame("TIT2", s); } -void ID3v2::Tag::setArtist(const String &s) -{ +void ID3v2::Tag::setArtist(const String &s) { setTextFrame("TPE1", s); } -void ID3v2::Tag::setAlbum(const String &s) -{ +void ID3v2::Tag::setAlbum(const String &s) { setTextFrame("TALB", s); } -void ID3v2::Tag::setComment(const String &s) -{ - if(s.isEmpty()) { +void ID3v2::Tag::setComment(const String &s) { + if (s.isEmpty()) { removeFrames("COMM"); return; } - if(!d->frameListMap["COMM"].isEmpty()) + if (!d->frameListMap["COMM"].isEmpty()) d->frameListMap["COMM"].front()->setText(s); else { CommentsFrame *f = new CommentsFrame(d->factory->defaultTextEncoding()); @@ -259,9 +233,8 @@ void ID3v2::Tag::setComment(const String &s) } } -void ID3v2::Tag::setGenre(const String &s) -{ - if(s.isEmpty()) { +void ID3v2::Tag::setGenre(const String &s) { + if (s.isEmpty()) { removeFrames("TCON"); return; } @@ -273,7 +246,7 @@ void ID3v2::Tag::setGenre(const String &s) int index = ID3v1::genreIndex(s); - if(index != 255) + if (index != 255) setTextFrame("TCON", String::number(index)); else setTextFrame("TCON", s); @@ -285,67 +258,56 @@ void ID3v2::Tag::setGenre(const String &s) #endif } -void ID3v2::Tag::setYear(unsigned int i) -{ - if(i == 0) { +void ID3v2::Tag::setYear(unsigned int i) { + if (i == 0) { removeFrames("TDRC"); return; } setTextFrame("TDRC", String::number(i)); } -void ID3v2::Tag::setTrack(unsigned int i) -{ - if(i == 0) { +void ID3v2::Tag::setTrack(unsigned int i) { + if (i == 0) { removeFrames("TRCK"); return; } setTextFrame("TRCK", String::number(i)); } -bool ID3v2::Tag::isEmpty() const -{ +bool ID3v2::Tag::isEmpty() const { return d->frameList.isEmpty(); } -Header *ID3v2::Tag::header() const -{ +Header *ID3v2::Tag::header() const { return &(d->header); } -ExtendedHeader *ID3v2::Tag::extendedHeader() const -{ +ExtendedHeader *ID3v2::Tag::extendedHeader() const { return d->extendedHeader; } -Footer *ID3v2::Tag::footer() const -{ +Footer *ID3v2::Tag::footer() const { return d->footer; } -const FrameListMap &ID3v2::Tag::frameListMap() const -{ +const FrameListMap &ID3v2::Tag::frameListMap() const { return d->frameListMap; } -const FrameList &ID3v2::Tag::frameList() const -{ +const FrameList &ID3v2::Tag::frameList() const { return d->frameList; } -const FrameList &ID3v2::Tag::frameList(const ByteVector &frameID) const -{ +const FrameList &ID3v2::Tag::frameList(const ByteVector &frameID) const { return d->frameListMap[frameID]; } -void ID3v2::Tag::addFrame(Frame *frame) -{ +void ID3v2::Tag::addFrame(Frame *frame) { d->frameList.append(frame); d->frameListMap[frame->frameID()].append(frame); } -void ID3v2::Tag::removeFrame(Frame *frame, bool del) -{ +void ID3v2::Tag::removeFrame(Frame *frame, bool del) { // remove the frame from the frame list FrameList::Iterator it = d->frameList.find(frame); d->frameList.erase(it); @@ -355,69 +317,65 @@ void ID3v2::Tag::removeFrame(Frame *frame, bool del) d->frameListMap[frame->frameID()].erase(it); // ...and delete as desired - if(del) + if (del) delete frame; } -void ID3v2::Tag::removeFrames(const ByteVector &id) -{ +void ID3v2::Tag::removeFrames(const ByteVector &id) { FrameList l = d->frameListMap[id]; - for(FrameList::ConstIterator it = l.begin(); it != l.end(); ++it) + for (FrameList::ConstIterator it = l.begin(); it != l.end(); ++it) removeFrame(*it, true); } -PropertyMap ID3v2::Tag::properties() const -{ +PropertyMap ID3v2::Tag::properties() const { PropertyMap properties; - for(FrameList::ConstIterator it = frameList().begin(); it != frameList().end(); ++it) { + for (FrameList::ConstIterator it = frameList().begin(); it != frameList().end(); ++it) { PropertyMap props = (*it)->asProperties(); properties.merge(props); } return properties; } -void ID3v2::Tag::removeUnsupportedProperties(const StringList &properties) -{ - for(StringList::ConstIterator it = properties.begin(); it != properties.end(); ++it){ - if(it->startsWith("UNKNOWN/")) { +void ID3v2::Tag::removeUnsupportedProperties(const StringList &properties) { + for (StringList::ConstIterator it = properties.begin(); it != properties.end(); ++it) { + if (it->startsWith("UNKNOWN/")) { String frameID = it->substr(String("UNKNOWN/").size()); - if(frameID.size() != 4) - continue; // invalid specification + if (frameID.size() != 4) + continue; // invalid specification ByteVector id = frameID.data(String::Latin1); // delete all unknown frames of given type FrameList l = frameList(id); - for(FrameList::ConstIterator fit = l.begin(); fit != l.end(); fit++) + for (FrameList::ConstIterator fit = l.begin(); fit != l.end(); fit++) if (dynamic_cast(*fit) != 0) removeFrame(*fit); } - else if(it->size() == 4){ + else if (it->size() == 4) { ByteVector id = it->data(String::Latin1); removeFrames(id); } else { - ByteVector id = it->substr(0,4).data(String::Latin1); - if(it->size() <= 5) - continue; // invalid specification + ByteVector id = it->substr(0, 4).data(String::Latin1); + if (it->size() <= 5) + continue; // invalid specification String description = it->substr(5); Frame *frame = 0; - if(id == "TXXX") + if (id == "TXXX") frame = UserTextIdentificationFrame::find(this, description); - else if(id == "WXXX") + else if (id == "WXXX") frame = UserUrlLinkFrame::find(this, description); - else if(id == "COMM") + else if (id == "COMM") frame = CommentsFrame::findByDescription(this, description); - else if(id == "USLT") + else if (id == "USLT") frame = UnsynchronizedLyricsFrame::findByDescription(this, description); - else if(id == "UFID") + else if (id == "UFID") frame = UniqueFileIdentifierFrame::findByOwner(this, description); - if(frame) + if (frame) removeFrame(frame); } } } -PropertyMap ID3v2::Tag::setProperties(const PropertyMap &origProps) -{ +PropertyMap ID3v2::Tag::setProperties(const PropertyMap &origProps) { FrameList framesToDelete; // we split up the PropertyMap into the "normal" keys and the "complicated" ones, // which are those according to TIPL or TMCL frames. @@ -425,48 +383,48 @@ PropertyMap ID3v2::Tag::setProperties(const PropertyMap &origProps) PropertyMap tiplProperties; PropertyMap tmclProperties; Frame::splitProperties(origProps, properties, tiplProperties, tmclProperties); - for(FrameListMap::ConstIterator it = frameListMap().begin(); it != frameListMap().end(); ++it){ - for(FrameList::ConstIterator lit = it->second.begin(); lit != it->second.end(); ++lit){ + for (FrameListMap::ConstIterator it = frameListMap().begin(); it != frameListMap().end(); ++it) { + for (FrameList::ConstIterator lit = it->second.begin(); lit != it->second.end(); ++lit) { PropertyMap frameProperties = (*lit)->asProperties(); - if(it->first == "TIPL") { + if (it->first == "TIPL") { if (tiplProperties != frameProperties) framesToDelete.append(*lit); else tiplProperties.erase(frameProperties); - } else if(it->first == "TMCL") { + } + else if (it->first == "TMCL") { if (tmclProperties != frameProperties) framesToDelete.append(*lit); else tmclProperties.erase(frameProperties); - } else if(!properties.contains(frameProperties)) + } + else if (!properties.contains(frameProperties)) framesToDelete.append(*lit); else properties.erase(frameProperties); } } - for(FrameList::ConstIterator it = framesToDelete.begin(); it != framesToDelete.end(); ++it) + for (FrameList::ConstIterator it = framesToDelete.begin(); it != framesToDelete.end(); ++it) removeFrame(*it); // now create remaining frames: // start with the involved people list (TIPL) - if(!tiplProperties.isEmpty()) - addFrame(TextIdentificationFrame::createTIPLFrame(tiplProperties)); + if (!tiplProperties.isEmpty()) + addFrame(TextIdentificationFrame::createTIPLFrame(tiplProperties)); // proceed with the musician credit list (TMCL) - if(!tmclProperties.isEmpty()) - addFrame(TextIdentificationFrame::createTMCLFrame(tmclProperties)); + if (!tmclProperties.isEmpty()) + addFrame(TextIdentificationFrame::createTMCLFrame(tmclProperties)); // now create the "one key per frame" frames - for(PropertyMap::ConstIterator it = properties.begin(); it != properties.end(); ++it) + for (PropertyMap::ConstIterator it = properties.begin(); it != properties.end(); ++it) addFrame(Frame::createTextualFrame(it->first, it->second)); - return PropertyMap(); // ID3 implements the complete PropertyMap interface, so an empty map is returned + return PropertyMap(); // ID3 implements the complete PropertyMap interface, so an empty map is returned } -ByteVector ID3v2::Tag::render() const -{ +ByteVector ID3v2::Tag::render() const { return render(ID3v2::v4); } -void ID3v2::Tag::downgradeFrames(FrameList *frames, FrameList *newFrames) const -{ +void ID3v2::Tag::downgradeFrames(FrameList *frames, FrameList *newFrames) const { #ifdef NO_ITUNES_HACKS const char *unsupportedFrames[] = { "ASPI", "EQU2", "RVA2", "SEEK", "SIGN", "TDRL", "TDTG", @@ -483,59 +441,58 @@ void ID3v2::Tag::downgradeFrames(FrameList *frames, FrameList *newFrames) const ID3v2::TextIdentificationFrame *frameTDRC = 0; ID3v2::TextIdentificationFrame *frameTIPL = 0; ID3v2::TextIdentificationFrame *frameTMCL = 0; - for(FrameList::ConstIterator it = d->frameList.begin(); it != d->frameList.end(); it++) { + for (FrameList::ConstIterator it = d->frameList.begin(); it != d->frameList.end(); it++) { ID3v2::Frame *frame = *it; ByteVector frameID = frame->header()->frameID(); - for(int i = 0; unsupportedFrames[i]; i++) { - if(frameID == unsupportedFrames[i]) { - debug("A frame that is not supported in ID3v2.3 \'" - + String(frameID) + "\' has been discarded"); + for (int i = 0; unsupportedFrames[i]; i++) { + if (frameID == unsupportedFrames[i]) { + debug("A frame that is not supported in ID3v2.3 \'" + String(frameID) + "\' has been discarded"); frame = 0; break; } } - if(frame && frameID == "TDOR") { + if (frame && frameID == "TDOR") { frameTDOR = dynamic_cast(frame); frame = 0; } - if(frame && frameID == "TDRC") { + if (frame && frameID == "TDRC") { frameTDRC = dynamic_cast(frame); frame = 0; } - if(frame && frameID == "TIPL") { + if (frame && frameID == "TIPL") { frameTIPL = dynamic_cast(frame); frame = 0; } - if(frame && frameID == "TMCL") { + if (frame && frameID == "TMCL") { frameTMCL = dynamic_cast(frame); frame = 0; } - if(frame) { + if (frame) { frames->append(frame); } } - if(frameTDOR) { + if (frameTDOR) { String content = frameTDOR->toString(); - if(content.size() >= 4) { + if (content.size() >= 4) { ID3v2::TextIdentificationFrame *frameTORY = new ID3v2::TextIdentificationFrame("TORY", String::Latin1); frameTORY->setText(content.substr(0, 4)); frames->append(frameTORY); newFrames->append(frameTORY); } } - if(frameTDRC) { + if (frameTDRC) { String content = frameTDRC->toString(); - if(content.size() >= 4) { + if (content.size() >= 4) { ID3v2::TextIdentificationFrame *frameTYER = new ID3v2::TextIdentificationFrame("TYER", String::Latin1); frameTYER->setText(content.substr(0, 4)); frames->append(frameTYER); newFrames->append(frameTYER); - if(content.size() >= 10 && content[4] == '-' && content[7] == '-') { + if (content.size() >= 10 && content[4] == '-' && content[7] == '-') { ID3v2::TextIdentificationFrame *frameTDAT = new ID3v2::TextIdentificationFrame("TDAT", String::Latin1); frameTDAT->setText(content.substr(8, 2) + content.substr(5, 2)); frames->append(frameTDAT); newFrames->append(frameTDAT); - if(content.size() >= 16 && content[10] == 'T' && content[13] == ':') { + if (content.size() >= 16 && content[10] == 'T' && content[13] == ':') { ID3v2::TextIdentificationFrame *frameTIME = new ID3v2::TextIdentificationFrame("TIME", String::Latin1); frameTIME->setText(content.substr(11, 2) + content.substr(14, 2)); frames->append(frameTIME); @@ -544,21 +501,21 @@ void ID3v2::Tag::downgradeFrames(FrameList *frames, FrameList *newFrames) const } } } - if(frameTIPL || frameTMCL) { + if (frameTIPL || frameTMCL) { ID3v2::TextIdentificationFrame *frameIPLS = new ID3v2::TextIdentificationFrame("IPLS", String::Latin1); StringList people; - if(frameTMCL) { + if (frameTMCL) { StringList v24People = frameTMCL->fieldList(); - for(unsigned int i = 0; i + 1 < v24People.size(); i += 2) { + for (unsigned int i = 0; i + 1 < v24People.size(); i += 2) { people.append(v24People[i]); - people.append(v24People[i+1]); + people.append(v24People[i + 1]); } } - if(frameTIPL) { + if (frameTIPL) { StringList v24People = frameTIPL->fieldList(); - for(unsigned int i = 0; i + 1 < v24People.size(); i += 2) { + for (unsigned int i = 0; i + 1 < v24People.size(); i += 2) { people.append(v24People[i]); - people.append(v24People[i+1]); + people.append(v24People[i + 1]); } } frameIPLS->setText(people); @@ -567,13 +524,11 @@ void ID3v2::Tag::downgradeFrames(FrameList *frames, FrameList *newFrames) const } } -ByteVector ID3v2::Tag::render(int version) const -{ +ByteVector ID3v2::Tag::render(int version) const { return render(version == 3 ? v3 : v4); } -ByteVector ID3v2::Tag::render(Version version) const -{ +ByteVector ID3v2::Tag::render(Version version) const { // We need to render the "tag data" first so that we have to correct size to // render in the tag's header. The "tag data" -- everything that is included // in ID3v2::Header::tagSize() -- includes the extended header, frames and @@ -587,7 +542,7 @@ ByteVector ID3v2::Tag::render(Version version) const newFrames.setAutoDelete(true); FrameList frameList; - if(version == v4) { + if (version == v4) { frameList = d->frameList; } else { @@ -600,18 +555,16 @@ ByteVector ID3v2::Tag::render(Version version) const // Loop through the frames rendering them and adding them to the tagData. - for(FrameList::ConstIterator it = frameList.begin(); it != frameList.end(); it++) { + for (FrameList::ConstIterator it = frameList.begin(); it != frameList.end(); it++) { (*it)->header()->setVersion(version == v3 ? 3 : 4); - if((*it)->header()->frameID().size() != 4) { - debug("An ID3v2 frame of unsupported or unknown type \'" - + String((*it)->header()->frameID()) + "\' has been discarded"); + if ((*it)->header()->frameID().size() != 4) { + debug("An ID3v2 frame of unsupported or unknown type \'" + String((*it)->header()->frameID()) + "\' has been discarded"); continue; } - if(!(*it)->header()->tagAlterPreservation()) { + if (!(*it)->header()->tagAlterPreservation()) { const ByteVector frameData = (*it)->render(); - if(frameData.size() == Frame::headerSize((*it)->header()->version())) { - debug("An empty ID3v2 frame \'" - + String((*it)->header()->frameID()) + "\' has been discarded"); + if (frameData.size() == Frame::headerSize((*it)->header()->version())) { + debug("An empty ID3v2 frame \'" + String((*it)->header()->frameID()) + "\' has been discarded"); continue; } tagData.append(frameData); @@ -623,7 +576,7 @@ ByteVector ID3v2::Tag::render(Version version) const long originalSize = d->header.tagSize(); long paddingSize = originalSize - (tagData.size() - Header::size()); - if(paddingSize <= 0) { + if (paddingSize <= 0) { paddingSize = MinPaddingSize; } else { @@ -633,7 +586,7 @@ ByteVector ID3v2::Tag::render(Version version) const threshold = std::max(threshold, MinPaddingSize); threshold = std::min(threshold, MaxPaddingSize); - if(paddingSize > threshold) + if (paddingSize > threshold) paddingSize = MinPaddingSize; } @@ -650,14 +603,12 @@ ByteVector ID3v2::Tag::render(Version version) const return tagData; } -Latin1StringHandler const *ID3v2::Tag::latin1StringHandler() -{ +Latin1StringHandler const *ID3v2::Tag::latin1StringHandler() { return stringHandler; } -void ID3v2::Tag::setLatin1StringHandler(const Latin1StringHandler *handler) -{ - if(handler) +void ID3v2::Tag::setLatin1StringHandler(const Latin1StringHandler *handler) { + if (handler) stringHandler = handler; else stringHandler = &defaultStringHandler; @@ -667,12 +618,11 @@ void ID3v2::Tag::setLatin1StringHandler(const Latin1StringHandler *handler) // protected members //////////////////////////////////////////////////////////////////////////////// -void ID3v2::Tag::read() -{ - if(!d->file) +void ID3v2::Tag::read() { + if (!d->file) return; - if(!d->file->isOpen()) + if (!d->file->isOpen()) return; d->file->seek(d->tagOffset); @@ -681,7 +631,7 @@ void ID3v2::Tag::read() // If the tag size is 0, then this is an invalid tag (tags must contain at // least one frame) - if(d->header.tagSize() != 0) + if (d->header.tagSize() != 0) parse(d->file->readBlock(d->header.tagSize())); // Look for duplicate ID3v2 tags and treat them as an extra blank of this one. @@ -692,28 +642,27 @@ void ID3v2::Tag::read() unsigned int extraSize = 0; - while(true) { + while (true) { d->file->seek(d->tagOffset + d->header.completeTagSize() + extraSize); const ByteVector data = d->file->readBlock(Header::size()); - if(data.size() < Header::size() || !data.startsWith(Header::fileIdentifier())) + if (data.size() < Header::size() || !data.startsWith(Header::fileIdentifier())) break; extraSize += Header(data).completeTagSize(); } - if(extraSize != 0) { + if (extraSize != 0) { debug("ID3v2::Tag::read() - Duplicate ID3v2 tags found."); d->header.setTagSize(d->header.tagSize() + extraSize); } } -void ID3v2::Tag::parse(const ByteVector &origData) -{ +void ID3v2::Tag::parse(const ByteVector &origData) { ByteVector data = origData; - if(d->header.unsynchronisation() && d->header.majorVersion() <= 3) + if (d->header.unsynchronisation() && d->header.majorVersion() <= 3) data = SynchData::decode(data); unsigned int frameDataPosition = 0; @@ -721,11 +670,11 @@ void ID3v2::Tag::parse(const ByteVector &origData) // check for extended header - if(d->header.extendedHeader()) { - if(!d->extendedHeader) + if (d->header.extendedHeader()) { + if (!d->extendedHeader) d->extendedHeader = new ExtendedHeader(); d->extendedHeader->setData(data); - if(d->extendedHeader->size() <= data.size()) { + if (d->extendedHeader->size() <= data.size()) { frameDataPosition += d->extendedHeader->size(); frameDataLength -= d->extendedHeader->size(); } @@ -735,7 +684,7 @@ void ID3v2::Tag::parse(const ByteVector &origData) // contain the same data as the header, but we do need to account for its // size. - if(d->header.footerPresent() && Footer::size() <= frameDataLength) + if (d->header.footerPresent() && Footer::size() <= frameDataLength) frameDataLength -= Footer::size(); // parse frames @@ -743,13 +692,13 @@ void ID3v2::Tag::parse(const ByteVector &origData) // Make sure that there is at least enough room in the remaining frame data for // a frame header. - while(frameDataPosition < frameDataLength - Frame::headerSize(d->header.majorVersion())) { + while (frameDataPosition < frameDataLength - Frame::headerSize(d->header.majorVersion())) { // If the next data is position is 0, assume that we've hit the padding // portion of the frame data. - if(data.at(frameDataPosition) == 0) { - if(d->header.footerPresent()) { + if (data.at(frameDataPosition) == 0) { + if (d->header.footerPresent()) { debug("Padding *and* a footer found. This is not allowed by the spec."); } @@ -757,14 +706,14 @@ void ID3v2::Tag::parse(const ByteVector &origData) } Frame *frame = d->factory->createFrame(data.mid(frameDataPosition), - &d->header); + &d->header); - if(!frame) + if (!frame) return; // Checks to make sure that frame parsed correctly. - if(frame->size() <= 0) { + if (frame->size() <= 0) { delete frame; return; } @@ -776,14 +725,13 @@ void ID3v2::Tag::parse(const ByteVector &origData) d->factory->rebuildAggregateFrames(this); } -void ID3v2::Tag::setTextFrame(const ByteVector &id, const String &value) -{ - if(value.isEmpty()) { +void ID3v2::Tag::setTextFrame(const ByteVector &id, const String &value) { + if (value.isEmpty()) { removeFrames(id); return; } - if(!d->frameListMap[id].isEmpty()) + if (!d->frameListMap[id].isEmpty()) d->frameListMap[id].front()->setText(value); else { const String::Type encoding = d->factory->defaultTextEncoding(); diff --git a/3rdparty/taglib/mpeg/id3v2/id3v2tag.h b/3rdparty/taglib/mpeg/id3v2/id3v2tag.h index f37f06c27..cf604bf19 100644 --- a/3rdparty/taglib/mpeg/id3v2/id3v2tag.h +++ b/3rdparty/taglib/mpeg/id3v2/id3v2tag.h @@ -39,20 +39,20 @@ namespace Strawberry_TagLib { namespace TagLib { - class File; +class File; - namespace ID3v2 { +namespace ID3v2 { - class Header; - class ExtendedHeader; - class Footer; +class Header; +class ExtendedHeader; +class Footer; - typedef List FrameList; - typedef Map FrameListMap; +typedef List FrameList; +typedef Map FrameListMap; - //! An abstraction for the ISO-8859-1 string to data encoding in ID3v2 tags. +//! An abstraction for the ISO-8859-1 string to data encoding in ID3v2 tags. - /*! +/*! * ID3v2 tag can store strings in ISO-8859-1 (Latin1), and TagLib only * supports genuine ISO-8859-1 by default. However, in practice, non * ISO-8859-1 encodings are often used instead of ISO-8859-1, such as @@ -67,22 +67,21 @@ namespace TagLib { * * \see ID3v2::Tag::setStringHandler() */ - class TAGLIB_EXPORT Latin1StringHandler - { - public: - Latin1StringHandler(); - virtual ~Latin1StringHandler(); +class TAGLIB_EXPORT Latin1StringHandler { + public: + Latin1StringHandler(); + virtual ~Latin1StringHandler(); - /*! + /*! * Decode a string from \a data. The default implementation assumes that * \a data is an ISO-8859-1 (Latin1) character array. */ - virtual String parse(const ByteVector &data) const; - }; + virtual String parse(const ByteVector &data) const; +}; - //! The main class in the ID3v2 implementation +//! The main class in the ID3v2 implementation - /*! +/*! * This is the main class in the ID3v2 implementation. It serves two * functions. This first, as is obvious from the public API, is to provide a * container for the other ID3v2 related classes. In addition, through the @@ -125,17 +124,16 @@ namespace TagLib { * working knowledge of ID3v2 structure. You're been warned. */ - class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag - { - public: - /*! +class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag { + public: + /*! * Constructs an empty ID3v2 tag. * * \note You must create at least one frame for this tag to be valid. */ - Tag(); + Tag(); - /*! + /*! * Constructs an ID3v2 tag read from \a file starting at \a tagOffset. * \a factory specifies which FrameFactory will be used for the * construction of new frames. @@ -147,46 +145,46 @@ namespace TagLib { * * \see FrameFactory */ - Tag(File *file, long tagOffset, - const FrameFactory *factory = FrameFactory::instance()); + Tag(File *file, long tagOffset, + const FrameFactory *factory = FrameFactory::instance()); - /*! + /*! * Destroys this Tag instance. */ - virtual ~Tag(); + virtual ~Tag(); - // Reimplementations. + // Reimplementations. - virtual String title() const; - virtual String artist() const; - virtual String album() const; - virtual String comment() const; - virtual String genre() const; - virtual unsigned int year() const; - virtual unsigned int track() const; + virtual String title() const; + virtual String artist() const; + virtual String album() const; + virtual String comment() const; + virtual String genre() const; + virtual unsigned int year() const; + virtual unsigned int track() const; - virtual void setTitle(const String &s); - virtual void setArtist(const String &s); - virtual void setAlbum(const String &s); - virtual void setComment(const String &s); - virtual void setGenre(const String &s); - virtual void setYear(unsigned int i); - virtual void setTrack(unsigned int i); + virtual void setTitle(const String &s); + virtual void setArtist(const String &s); + virtual void setAlbum(const String &s); + virtual void setComment(const String &s); + virtual void setGenre(const String &s); + virtual void setYear(unsigned int i); + virtual void setTrack(unsigned int i); - virtual bool isEmpty() const; + virtual bool isEmpty() const; - /*! + /*! * Returns a pointer to the tag's header. */ - Header *header() const; + Header *header() const; - /*! + /*! * Returns a pointer to the tag's extended header or null if there is no * extended header. */ - ExtendedHeader *extendedHeader() const; + ExtendedHeader *extendedHeader() const; - /*! + /*! * Returns a pointer to the tag's footer or null if there is no footer. * * \deprecated I don't see any reason to keep this around since there's @@ -194,9 +192,9 @@ namespace TagLib { * prone to change my mind, so this gets to stay around until near a * release. */ - TAGLIB_DEPRECATED Footer *footer() const; + TAGLIB_DEPRECATED Footer *footer() const; - /*! + /*! * Returns a reference to the frame list map. This is an FrameListMap of * all of the frames in the tag. * @@ -230,9 +228,9 @@ namespace TagLib { * * \see frameList() */ - const FrameListMap &frameListMap() const; + const FrameListMap &frameListMap() const; - /*! + /*! * Returns a reference to the frame list. This is an FrameList of all of * the frames in the tag in the order that they were parsed. * @@ -242,9 +240,9 @@ namespace TagLib { * \warning You should not modify this data structure directly, instead * use addFrame() and removeFrame(). */ - const FrameList &frameList() const; + const FrameList &frameList() const; - /*! + /*! * Returns the frame list for frames with the id \a frameID or an empty * list if there are no frames of that type. This is just a convenience * and is equivalent to: @@ -255,35 +253,35 @@ namespace TagLib { * * \see frameListMap() */ - const FrameList &frameList(const ByteVector &frameID) const; + const FrameList &frameList(const ByteVector &frameID) const; - /*! + /*! * Add a frame to the tag. At this point the tag takes ownership of * the frame and will handle freeing its memory. * * \note Using this method will invalidate any pointers on the list * returned by frameList() */ - void addFrame(Frame *frame); + void addFrame(Frame *frame); - /*! + /*! * Remove a frame from the tag. If \a del is true the frame's memory * will be freed; if it is false, it must be deleted by the user. * * \note Using this method will invalidate any pointers on the list * returned by frameList() */ - void removeFrame(Frame *frame, bool del = true); + void removeFrame(Frame *frame, bool del = true); - /*! + /*! * Remove all frames of type \a id from the tag and free their memory. * * \note Using this method will invalidate any pointers on the list * returned by frameList() */ - void removeFrames(const ByteVector &id); + void removeFrames(const ByteVector &id); - /*! + /*! * Implements the unified property interface -- export function. * This function does some work to translate the hard-specified ID3v2 * frame types into a free-form string-to-stringlist PropertyMap: @@ -312,9 +310,9 @@ namespace TagLib { * once, the description, separated by a "/". * */ - PropertyMap properties() const; + PropertyMap properties() const; - /*! + /*! * Removes unsupported frames given by \a properties. The elements of * \a properties must be taken from properties().unsupportedData(); they * are of one of the following forms: @@ -325,41 +323,41 @@ namespace TagLib { * - "UNKNOWN/" + frameID, for frames that could not be parsed by TagLib. * In that case, *all* unknown frames with the given ID will be removed. */ - void removeUnsupportedProperties(const StringList &properties); + void removeUnsupportedProperties(const StringList &properties); - /*! + /*! * Implements the unified property interface -- import function. * See the comments in properties(). */ - PropertyMap setProperties(const PropertyMap &); + PropertyMap setProperties(const PropertyMap &); - /*! + /*! * Render the tag back to binary data, suitable to be written to disk. */ - ByteVector render() const; + ByteVector render() const; - /*! + /*! * \deprecated */ - TAGLIB_DEPRECATED ByteVector render(int version) const; + TAGLIB_DEPRECATED ByteVector render(int version) const; - /*! + /*! * Render the tag back to binary data, suitable to be written to disk. * * The \a version parameter specifies whether ID3v2.4 (default) or ID3v2.3 * should be used. */ - ByteVector render(Version version) const; + ByteVector render(Version version) const; - /*! + /*! * Gets the current string handler that decides how the "Latin-1" data * will be converted to and from binary data. * * \see Latin1StringHandler */ - static Latin1StringHandler const *latin1StringHandler(); + static Latin1StringHandler const *latin1StringHandler(); - /*! + /*! * Sets the string handler that decides how the "Latin-1" data will be * converted to and from binary data. * If the parameter \a handler is null, the previous handler is @@ -370,44 +368,44 @@ namespace TagLib { * * \see Latin1StringHandler */ - static void setLatin1StringHandler(const Latin1StringHandler *handler); + static void setLatin1StringHandler(const Latin1StringHandler *handler); - protected: - /*! + protected: + /*! * Reads data from the file specified in the constructor. It does basic * parsing of the data in the largest chunks. It partitions the tag into * the Header, the body of the tag (which contains the ExtendedHeader and * frames) and Footer. */ - void read(); + void read(); - /*! + /*! * This is called by read to parse the body of the tag. It determines if an * extended header exists and adds frames to the FrameListMap. */ - void parse(const ByteVector &data); + void parse(const ByteVector &data); - /*! + /*! * Sets the value of the text frame with the Frame ID \a id to \a value. * If the frame does not exist, it is created. */ - void setTextFrame(const ByteVector &id, const String &value); + void setTextFrame(const ByteVector &id, const String &value); - /*! + /*! * Dowgrade frames from ID3v2.4 (used internally and by default) to ID3v2.3 */ - void downgradeFrames(FrameList *existingFrames, FrameList *newFrames) const; + void downgradeFrames(FrameList *existingFrames, FrameList *newFrames) const; - private: - Tag(const Tag &); - Tag &operator=(const Tag &); + private: + Tag(const Tag &); + Tag &operator=(const Tag &); - class TagPrivate; - TagPrivate *d; - }; + class TagPrivate; + TagPrivate *d; +}; - } -} -} +} // namespace ID3v2 +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/mpegfile.cpp b/3rdparty/taglib/mpeg/mpegfile.cpp index 552e27442..653881abc 100644 --- a/3rdparty/taglib/mpeg/mpegfile.cpp +++ b/3rdparty/taglib/mpeg/mpegfile.cpp @@ -39,25 +39,23 @@ using namespace Strawberry_TagLib::TagLib; -namespace -{ - enum { ID3v2Index = 0, APEIndex = 1, ID3v1Index = 2 }; +namespace { +enum { ID3v2Index = 0, + APEIndex = 1, + ID3v1Index = 2 }; } -class MPEG::File::FilePrivate -{ -public: - explicit FilePrivate(const ID3v2::FrameFactory *frameFactory = ID3v2::FrameFactory::instance()) : - ID3v2FrameFactory(frameFactory), - ID3v2Location(-1), - ID3v2OriginalSize(0), - APELocation(-1), - APEOriginalSize(0), - ID3v1Location(-1), - properties(0) {} +class MPEG::File::FilePrivate { + public: + explicit FilePrivate(const ID3v2::FrameFactory *frameFactory = ID3v2::FrameFactory::instance()) : ID3v2FrameFactory(frameFactory), + ID3v2Location(-1), + ID3v2OriginalSize(0), + APELocation(-1), + APEOriginalSize(0), + ID3v1Location(-1), + properties(0) {} - ~FilePrivate() - { + ~FilePrivate() { delete properties; } @@ -80,24 +78,21 @@ public: // static members //////////////////////////////////////////////////////////////////////////////// -namespace -{ - // Dummy file class to make a stream work with MPEG::Header. +namespace { +// Dummy file class to make a stream work with MPEG::Header. - class AdapterFile : public Strawberry_TagLib::TagLib::File - { - public: - explicit AdapterFile(IOStream *stream) : File(stream) {} +class AdapterFile : public Strawberry_TagLib::TagLib::File { + public: + explicit AdapterFile(IOStream *stream) : File(stream) {} - Tag *tag() const { return nullptr; } - AudioProperties *audioProperties() const { return nullptr; } - bool save() { return false; } - }; -} + Tag *tag() const { return nullptr; } + AudioProperties *audioProperties() const { return nullptr; } + bool save() { return false; } +}; +} // namespace -bool MPEG::File::isSupported(IOStream *stream) -{ - if(!stream || !stream->isOpen()) +bool MPEG::File::isSupported(IOStream *stream) { + if (!stream || !stream->isOpen()) return false; // An MPEG file has MPEG frame headers. An ID3v2 tag may precede. @@ -108,16 +103,16 @@ bool MPEG::File::isSupported(IOStream *stream) long headerOffset; const ByteVector buffer = Utils::readHeader(stream, bufferSize(), true, &headerOffset); - if(buffer.isEmpty()) + if (buffer.isEmpty()) return false; const long originalPosition = stream->tell(); AdapterFile file(stream); - for(unsigned int i = 0; i < buffer.size() - 1; ++i) { - if(isFrameSync(buffer, i)) { + for (unsigned int i = 0; i < buffer.size() - 1; ++i) { + if (isFrameSync(buffer, i)) { const Header header(&file, headerOffset + i, true); - if(header.isValid()) { + if (header.isValid()) { stream->seek(originalPosition); return true; } @@ -132,139 +127,121 @@ bool MPEG::File::isSupported(IOStream *stream) // public members //////////////////////////////////////////////////////////////////////////////// -MPEG::File::File(FileName file, bool readProperties, Properties::ReadStyle) : - Strawberry_TagLib::TagLib::File(file), - d(new FilePrivate()) -{ - if(isOpen()) +MPEG::File::File(FileName file, bool readProperties, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(file), + d(new FilePrivate()) { + if (isOpen()) read(readProperties); } MPEG::File::File(FileName file, ID3v2::FrameFactory *frameFactory, - bool readProperties, Properties::ReadStyle) : - Strawberry_TagLib::TagLib::File(file), - d(new FilePrivate(frameFactory)) -{ - if(isOpen()) + bool readProperties, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(file), + d(new FilePrivate(frameFactory)) { + if (isOpen()) read(readProperties); } MPEG::File::File(IOStream *stream, ID3v2::FrameFactory *frameFactory, - bool readProperties, Properties::ReadStyle) : - Strawberry_TagLib::TagLib::File(stream), - d(new FilePrivate(frameFactory)) -{ - if(isOpen()) + bool readProperties, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(stream), + d(new FilePrivate(frameFactory)) { + if (isOpen()) read(readProperties); } -MPEG::File::~File() -{ +MPEG::File::~File() { delete d; } -Strawberry_TagLib::TagLib::Tag *MPEG::File::tag() const -{ +Strawberry_TagLib::TagLib::Tag *MPEG::File::tag() const { return &d->tag; } -PropertyMap MPEG::File::properties() const -{ +PropertyMap MPEG::File::properties() const { return d->tag.properties(); } -void MPEG::File::removeUnsupportedProperties(const StringList &properties) -{ +void MPEG::File::removeUnsupportedProperties(const StringList &properties) { d->tag.removeUnsupportedProperties(properties); } -PropertyMap MPEG::File::setProperties(const PropertyMap &properties) -{ +PropertyMap MPEG::File::setProperties(const PropertyMap &properties) { // update ID3v1 tag if it exists, but ignore the return value - if(ID3v1Tag()) + if (ID3v1Tag()) ID3v1Tag()->setProperties(properties); return ID3v2Tag(true)->setProperties(properties); } -MPEG::Properties *MPEG::File::audioProperties() const -{ +MPEG::Properties *MPEG::File::audioProperties() const { return d->properties; } -bool MPEG::File::save() -{ +bool MPEG::File::save() { return save(AllTags); } -bool MPEG::File::save(int tags) -{ +bool MPEG::File::save(int tags) { return save(tags, StripOthers); } -bool MPEG::File::save(int tags, bool stripOthers) -{ +bool MPEG::File::save(int tags, bool stripOthers) { return save(tags, stripOthers ? StripOthers : StripNone, ID3v2::v4); } -bool MPEG::File::save(int tags, bool stripOthers, int id3v2Version) -{ +bool MPEG::File::save(int tags, bool stripOthers, int id3v2Version) { return save(tags, - stripOthers ? StripOthers : StripNone, - id3v2Version == 3 ? ID3v2::v3 : ID3v2::v4); + stripOthers ? StripOthers : StripNone, + id3v2Version == 3 ? ID3v2::v3 : ID3v2::v4); } -bool MPEG::File::save(int tags, bool stripOthers, int id3v2Version, bool duplicateTags) -{ +bool MPEG::File::save(int tags, bool stripOthers, int id3v2Version, bool duplicateTags) { return save(tags, - stripOthers ? StripOthers : StripNone, - id3v2Version == 3 ? ID3v2::v3 : ID3v2::v4, - duplicateTags ? Duplicate : DoNotDuplicate); + stripOthers ? StripOthers : StripNone, + id3v2Version == 3 ? ID3v2::v3 : ID3v2::v4, + duplicateTags ? Duplicate : DoNotDuplicate); } -bool MPEG::File::save(int tags, StripTags strip, ID3v2::Version version, DuplicateTags duplicate) -{ - if(readOnly()) { +bool MPEG::File::save(int tags, StripTags strip, ID3v2::Version version, DuplicateTags duplicate) { + if (readOnly()) { debug("MPEG::File::save() -- File is read only."); return false; } // Create the tags if we've been asked to. - if(duplicate == Duplicate) { + if (duplicate == Duplicate) { // Copy the values from the tag that does exist into the new tag, // except if the existing tag is to be stripped. - if((tags & ID3v2) && ID3v1Tag() && !(strip == StripOthers && !(tags & ID3v1))) + if ((tags & ID3v2) && ID3v1Tag() && !(strip == StripOthers && !(tags & ID3v1))) Tag::duplicate(ID3v1Tag(), ID3v2Tag(true), false); - if((tags & ID3v1) && d->tag[ID3v2Index] && !(strip == StripOthers && !(tags & ID3v2))) + if ((tags & ID3v1) && d->tag[ID3v2Index] && !(strip == StripOthers && !(tags & ID3v2))) Tag::duplicate(ID3v2Tag(), ID3v1Tag(true), false); } // Remove all the tags not going to be saved. - if(strip == StripOthers) + if (strip == StripOthers) File::strip(~tags, false); - if(ID3v2 & tags) { + if (ID3v2 & tags) { - if(ID3v2Tag() && !ID3v2Tag()->isEmpty()) { + if (ID3v2Tag() && !ID3v2Tag()->isEmpty()) { // ID3v2 tag is not empty. Update the old one or create a new one. - if(d->ID3v2Location < 0) + if (d->ID3v2Location < 0) d->ID3v2Location = 0; const ByteVector data = ID3v2Tag()->render(version); insert(data, d->ID3v2Location, d->ID3v2OriginalSize); - if(d->APELocation >= 0) + if (d->APELocation >= 0) d->APELocation += (static_cast(data.size()) - d->ID3v2OriginalSize); - if(d->ID3v1Location >= 0) + if (d->ID3v1Location >= 0) d->ID3v1Location += (static_cast(data.size()) - d->ID3v2OriginalSize); d->ID3v2OriginalSize = data.size(); @@ -277,13 +254,13 @@ bool MPEG::File::save(int tags, StripTags strip, ID3v2::Version version, Duplica } } - if(ID3v1 & tags) { + if (ID3v1 & tags) { - if(ID3v1Tag() && !ID3v1Tag()->isEmpty()) { + if (ID3v1Tag() && !ID3v1Tag()->isEmpty()) { // ID3v1 tag is not empty. Update the old one or create a new one. - if(d->ID3v1Location >= 0) { + if (d->ID3v1Location >= 0) { seek(d->ID3v1Location); } else { @@ -301,14 +278,14 @@ bool MPEG::File::save(int tags, StripTags strip, ID3v2::Version version, Duplica } } - if(APE & tags) { + if (APE & tags) { - if(APETag() && !APETag()->isEmpty()) { + if (APETag() && !APETag()->isEmpty()) { // APE tag is not empty. Update the old one or create a new one. - if(d->APELocation < 0) { - if(d->ID3v1Location >= 0) + if (d->APELocation < 0) { + if (d->ID3v1Location >= 0) d->APELocation = d->ID3v1Location; else d->APELocation = length(); @@ -317,7 +294,7 @@ bool MPEG::File::save(int tags, StripTags strip, ID3v2::Version version, Duplica const ByteVector data = APETag()->render(); insert(data, d->APELocation, d->APEOriginalSize); - if(d->ID3v1Location >= 0) + if (d->ID3v1Location >= 0) d->ID3v1Location += (static_cast(data.size()) - d->APEOriginalSize); d->APEOriginalSize = data.size(); @@ -333,95 +310,88 @@ bool MPEG::File::save(int tags, StripTags strip, ID3v2::Version version, Duplica return true; } -ID3v2::Tag *MPEG::File::ID3v2Tag(bool create) -{ +ID3v2::Tag *MPEG::File::ID3v2Tag(bool create) { return d->tag.access(ID3v2Index, create); } -ID3v1::Tag *MPEG::File::ID3v1Tag(bool create) -{ +ID3v1::Tag *MPEG::File::ID3v1Tag(bool create) { return d->tag.access(ID3v1Index, create); } -APE::Tag *MPEG::File::APETag(bool create) -{ +APE::Tag *MPEG::File::APETag(bool create) { return d->tag.access(APEIndex, create); } -bool MPEG::File::strip(int tags) -{ +bool MPEG::File::strip(int tags) { return strip(tags, true); } -bool MPEG::File::strip(int tags, bool freeMemory) -{ - if(readOnly()) { +bool MPEG::File::strip(int tags, bool freeMemory) { + if (readOnly()) { debug("MPEG::File::strip() - Cannot strip tags from a read only file."); return false; } - if((tags & ID3v2) && d->ID3v2Location >= 0) { + if ((tags & ID3v2) && d->ID3v2Location >= 0) { removeBlock(d->ID3v2Location, d->ID3v2OriginalSize); - if(d->APELocation >= 0) + if (d->APELocation >= 0) d->APELocation -= d->ID3v2OriginalSize; - if(d->ID3v1Location >= 0) + if (d->ID3v1Location >= 0) d->ID3v1Location -= d->ID3v2OriginalSize; d->ID3v2Location = -1; d->ID3v2OriginalSize = 0; - if(freeMemory) + if (freeMemory) d->tag.set(ID3v2Index, 0); } - if((tags & ID3v1) && d->ID3v1Location >= 0) { + if ((tags & ID3v1) && d->ID3v1Location >= 0) { truncate(d->ID3v1Location); d->ID3v1Location = -1; - if(freeMemory) + if (freeMemory) d->tag.set(ID3v1Index, 0); } - if((tags & APE) && d->APELocation >= 0) { + if ((tags & APE) && d->APELocation >= 0) { removeBlock(d->APELocation, d->APEOriginalSize); - if(d->ID3v1Location >= 0) + if (d->ID3v1Location >= 0) d->ID3v1Location -= d->APEOriginalSize; d->APELocation = -1; d->APEOriginalSize = 0; - if(freeMemory) + if (freeMemory) d->tag.set(APEIndex, 0); } return true; } -void MPEG::File::setID3v2FrameFactory(const ID3v2::FrameFactory *factory) -{ +void MPEG::File::setID3v2FrameFactory(const ID3v2::FrameFactory *factory) { d->ID3v2FrameFactory = factory; } -long MPEG::File::nextFrameOffset(long position) -{ +long MPEG::File::nextFrameOffset(long position) { ByteVector frameSyncBytes(2, '\0'); - while(true) { + while (true) { seek(position); const ByteVector buffer = readBlock(bufferSize()); - if(buffer.isEmpty()) + if (buffer.isEmpty()) return -1; - for(unsigned int i = 0; i < buffer.size(); ++i) { + for (unsigned int i = 0; i < buffer.size(); ++i) { frameSyncBytes[0] = frameSyncBytes[1]; frameSyncBytes[1] = buffer[i]; - if(isFrameSync(frameSyncBytes)) { + if (isFrameSync(frameSyncBytes)) { const Header header(this, position + i - 1, true); - if(header.isValid()) + if (header.isValid()) return position + i - 1; } } @@ -430,23 +400,22 @@ long MPEG::File::nextFrameOffset(long position) } } -long MPEG::File::previousFrameOffset(long position) -{ +long MPEG::File::previousFrameOffset(long position) { ByteVector frameSyncBytes(2, '\0'); - while(position > 0) { + while (position > 0) { const long bufferLength = std::min(position, bufferSize()); position -= bufferLength; seek(position); const ByteVector buffer = readBlock(bufferLength); - for(int i = buffer.size() - 1; i >= 0; --i) { + for (int i = buffer.size() - 1; i >= 0; --i) { frameSyncBytes[1] = frameSyncBytes[0]; frameSyncBytes[0] = buffer[i]; - if(isFrameSync(frameSyncBytes)) { + if (isFrameSync(frameSyncBytes)) { const Header header(this, position + i, true); - if(header.isValid()) + if (header.isValid()) return position + i + header.frameLength(); } } @@ -455,23 +424,21 @@ long MPEG::File::previousFrameOffset(long position) return -1; } -long MPEG::File::firstFrameOffset() -{ +long MPEG::File::firstFrameOffset() { long position = 0; - if(hasID3v2Tag()) + if (hasID3v2Tag()) position = d->ID3v2Location + ID3v2Tag()->header()->completeTagSize(); return nextFrameOffset(position); } -long MPEG::File::lastFrameOffset() -{ +long MPEG::File::lastFrameOffset() { long position; - if(hasAPETag()) + if (hasAPETag()) position = d->APELocation - 1; - else if(hasID3v1Tag()) + else if (hasID3v1Tag()) position = d->ID3v1Location - 1; else position = length(); @@ -479,18 +446,15 @@ long MPEG::File::lastFrameOffset() return previousFrameOffset(position); } -bool MPEG::File::hasID3v1Tag() const -{ +bool MPEG::File::hasID3v1Tag() const { return (d->ID3v1Location >= 0); } -bool MPEG::File::hasID3v2Tag() const -{ +bool MPEG::File::hasID3v2Tag() const { return (d->ID3v2Location >= 0); } -bool MPEG::File::hasAPETag() const -{ +bool MPEG::File::hasAPETag() const { return (d->APELocation >= 0); } @@ -498,13 +462,12 @@ bool MPEG::File::hasAPETag() const // private members //////////////////////////////////////////////////////////////////////////////// -void MPEG::File::read(bool readProperties) -{ +void MPEG::File::read(bool readProperties) { // Look for an ID3v2 tag d->ID3v2Location = findID3v2(); - if(d->ID3v2Location >= 0) { + if (d->ID3v2Location >= 0) { d->tag.set(ID3v2Index, new ID3v2::Tag(this, d->ID3v2Location, d->ID3v2FrameFactory)); d->ID3v2OriginalSize = ID3v2Tag()->header()->completeTagSize(); } @@ -513,20 +476,20 @@ void MPEG::File::read(bool readProperties) d->ID3v1Location = Utils::findID3v1(this); - if(d->ID3v1Location >= 0) + if (d->ID3v1Location >= 0) d->tag.set(ID3v1Index, new ID3v1::Tag(this, d->ID3v1Location)); // Look for an APE tag d->APELocation = Utils::findAPE(this, d->ID3v1Location); - if(d->APELocation >= 0) { + if (d->APELocation >= 0) { d->tag.set(APEIndex, new APE::Tag(this, d->APELocation)); d->APEOriginalSize = APETag()->footer()->completeTagSize(); d->APELocation = d->APELocation + APE::Footer::size() - d->APEOriginalSize; } - if(readProperties) + if (readProperties) d->properties = new Properties(this); // Make sure that we have our default tag types available. @@ -535,9 +498,8 @@ void MPEG::File::read(bool readProperties) ID3v1Tag(true); } -long MPEG::File::findID3v2() -{ - if(!isValid()) +long MPEG::File::findID3v2() { + if (!isValid()) return -1; // An ID3v2 tag or MPEG frame is most likely be at the beginning of the file. @@ -545,11 +507,11 @@ long MPEG::File::findID3v2() const ByteVector headerID = ID3v2::Header::fileIdentifier(); seek(0); - if(readBlock(headerID.size()) == headerID) + if (readBlock(headerID.size()) == headerID) return 0; const Header firstHeader(this, 0, true); - if(firstHeader.isValid()) + if (firstHeader.isValid()) return -1; // Look for an ID3v2 tag until reaching the first valid MPEG frame. @@ -558,25 +520,25 @@ long MPEG::File::findID3v2() ByteVector tagHeaderBytes(3, '\0'); long position = 0; - while(true) { + while (true) { seek(position); const ByteVector buffer = readBlock(bufferSize()); - if(buffer.isEmpty()) + if (buffer.isEmpty()) return -1; - for(unsigned int i = 0; i < buffer.size(); ++i) { + for (unsigned int i = 0; i < buffer.size(); ++i) { frameSyncBytes[0] = frameSyncBytes[1]; frameSyncBytes[1] = buffer[i]; - if(isFrameSync(frameSyncBytes)) { + if (isFrameSync(frameSyncBytes)) { const Header header(this, position + i - 1, true); - if(header.isValid()) + if (header.isValid()) return -1; } tagHeaderBytes[0] = tagHeaderBytes[1]; tagHeaderBytes[1] = tagHeaderBytes[2]; tagHeaderBytes[2] = buffer[i]; - if(tagHeaderBytes == headerID) + if (tagHeaderBytes == headerID) return position + i - 2; } diff --git a/3rdparty/taglib/mpeg/mpegfile.h b/3rdparty/taglib/mpeg/mpegfile.h index 7b4efec3b..7b06cb3e4 100644 --- a/3rdparty/taglib/mpeg/mpegfile.h +++ b/3rdparty/taglib/mpeg/mpegfile.h @@ -37,43 +37,49 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace ID3v2 { class Tag; class FrameFactory; } - namespace ID3v1 { class Tag; } - namespace APE { class Tag; } +namespace ID3v2 { +class Tag; +class FrameFactory; +} // namespace ID3v2 +namespace ID3v1 { +class Tag; +} +namespace APE { +class Tag; +} - //! An implementation of TagLib::File with MPEG (MP3) specific methods +//! An implementation of TagLib::File with MPEG (MP3) specific methods - namespace MPEG { +namespace MPEG { - //! An MPEG file class with some useful methods specific to MPEG +//! An MPEG file class with some useful methods specific to MPEG - /*! +/*! * This implements the generic TagLib::File API and additionally provides * access to properties that are distinct to MPEG files, notably access * to the different ID3 tags. */ - class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File - { - public: - /*! +class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File { + public: + /*! * This set of flags is used for various operations and is suitable for * being OR-ed together. */ - enum TagTypes { - //! Empty set. Matches no tag types. - NoTags = 0x0000, - //! Matches ID3v1 tags. - ID3v1 = 0x0001, - //! Matches ID3v2 tags. - ID3v2 = 0x0002, - //! Matches APE tags. - APE = 0x0004, - //! Matches all tag types. - AllTags = 0xffff - }; + enum TagTypes { + //! Empty set. Matches no tag types. + NoTags = 0x0000, + //! Matches ID3v1 tags. + ID3v1 = 0x0001, + //! Matches ID3v2 tags. + ID3v2 = 0x0002, + //! Matches APE tags. + APE = 0x0004, + //! Matches all tag types. + AllTags = 0xffff + }; - /*! + /*! * Constructs an MPEG file from \a file. If \a readProperties is true the * file's audio properties will also be read. * @@ -82,10 +88,10 @@ namespace TagLib { * \deprecated This constructor will be dropped in favor of the one below * in a future version. */ - File(FileName file, bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(FileName file, bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Constructs an MPEG file from \a file. If \a readProperties is true the * file's audio properties will also be read. * @@ -94,12 +100,12 @@ namespace TagLib { * * \note In the current implementation, \a propertiesStyle is ignored. */ - // BIC: merge with the above constructor - File(FileName file, ID3v2::FrameFactory *frameFactory, - bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + // BIC: merge with the above constructor + File(FileName file, ID3v2::FrameFactory *frameFactory, + bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Constructs an MPEG file from \a stream. If \a readProperties is true the * file's audio properties will also be read. * @@ -111,16 +117,16 @@ namespace TagLib { * * \note In the current implementation, \a propertiesStyle is ignored. */ - File(IOStream *stream, ID3v2::FrameFactory *frameFactory, - bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(IOStream *stream, ID3v2::FrameFactory *frameFactory, + bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Destroys this instance of the File. */ - virtual ~File(); + virtual ~File(); - /*! + /*! * Returns a pointer to a tag that is the union of the ID3v2 and ID3v1 * tags. The ID3v2 tag is given priority in reading the information -- if * requested information exists in both the ID3v2 tag and the ID3v1 tag, @@ -137,19 +143,19 @@ namespace TagLib { * \see ID3v2Tag() * \see APETag() */ - virtual Tag *tag() const; + virtual Tag *tag() const; - /*! + /*! * Implements the reading part of the unified property interface. * If the file contains more than one tag, only the * first one (in the order ID3v2, APE, ID3v1) will be converted to the * PropertyMap. */ - PropertyMap properties() const; + PropertyMap properties() const; - void removeUnsupportedProperties(const StringList &properties); + void removeUnsupportedProperties(const StringList &properties); - /*! + /*! * Implements the writing part of the unified tag dictionary interface. * In order to avoid problems with deprecated tag formats, this method * always creates an ID3v2 tag if necessary. @@ -157,15 +163,15 @@ namespace TagLib { * limitations of that format. * The returned PropertyMap refers to the ID3v2 tag only. */ - PropertyMap setProperties(const PropertyMap &); + PropertyMap setProperties(const PropertyMap &); - /*! + /*! * Returns the MPEG::Properties for this file. If no audio properties * were read then this will return a null pointer. */ - virtual Properties *audioProperties() const; + virtual Properties *audioProperties() const; - /*! + /*! * Save the file. If at least one tag -- ID3v1 or ID3v2 -- exists this * will duplicate its content into the other tag. This returns true * if saving was successful. @@ -180,9 +186,9 @@ namespace TagLib { * * \see save(int tags) */ - virtual bool save(); + virtual bool save(); - /*! + /*! * Save the file. This will attempt to save all of the tag types that are * specified by OR-ing together TagTypes values. The save() method above * uses AllTags. This returns true if saving was successful. @@ -191,27 +197,27 @@ namespace TagLib { * in memory, so later calls to save() which make use of these tags will * remain valid. This also strips empty tags. */ - bool save(int tags); + bool save(int tags); - /*! + /*! * \deprecated */ - // BIC: combine with the above method - TAGLIB_DEPRECATED bool save(int tags, bool stripOthers); + // BIC: combine with the above method + TAGLIB_DEPRECATED bool save(int tags, bool stripOthers); - /*! + /*! * \deprecated */ - // BIC: combine with the above method - TAGLIB_DEPRECATED bool save(int tags, bool stripOthers, int id3v2Version); + // BIC: combine with the above method + TAGLIB_DEPRECATED bool save(int tags, bool stripOthers, int id3v2Version); - /*! + /*! * \deprecated */ - // BIC: combine with the above method - TAGLIB_DEPRECATED bool save(int tags, bool stripOthers, int id3v2Version, bool duplicateTags); + // BIC: combine with the above method + TAGLIB_DEPRECATED bool save(int tags, bool stripOthers, int id3v2Version, bool duplicateTags); - /*! + /*! * Save the file. This will attempt to save all of the tag types that are * specified by OR-ing together TagTypes values. * @@ -224,11 +230,11 @@ namespace TagLib { * If \a duplicate is set to DuplicateTags and at least one tag -- ID3v1 * or ID3v2 -- exists this will duplicate its content into the other tag. */ - bool save(int tags, StripTags strip, - ID3v2::Version version = ID3v2::v4, - DuplicateTags duplicate = Duplicate); + bool save(int tags, StripTags strip, + ID3v2::Version version = ID3v2::v4, + DuplicateTags duplicate = Duplicate); - /*! + /*! * Returns a pointer to the ID3v2 tag of the file. * * If \a create is false (the default) this may return a null pointer @@ -245,9 +251,9 @@ namespace TagLib { * * \see hasID3v2Tag() */ - ID3v2::Tag *ID3v2Tag(bool create = false); + ID3v2::Tag *ID3v2Tag(bool create = false); - /*! + /*! * Returns a pointer to the ID3v1 tag of the file. * * If \a create is false (the default) this may return a null pointer @@ -264,9 +270,9 @@ namespace TagLib { * * \see hasID3v1Tag() */ - ID3v1::Tag *ID3v1Tag(bool create = false); + ID3v1::Tag *ID3v1Tag(bool create = false); - /*! + /*! * Returns a pointer to the APE tag of the file. * * If \a create is false (the default) this may return a null pointer @@ -283,9 +289,9 @@ namespace TagLib { * * \see hasAPETag() */ - APE::Tag *APETag(bool create = false); + APE::Tag *APETag(bool create = false); - /*! + /*! * This will strip the tags that match the OR-ed together TagTypes from the * file. By default it strips all tags. It returns true if the tags are * successfully stripped. @@ -297,9 +303,9 @@ namespace TagLib { * * \note This will update the file immediately. */ - bool strip(int tags = AllTags); + bool strip(int tags = AllTags); - /*! + /*! * This will strip the tags that match the OR-ed together TagTypes from the * file. By default it strips all tags. It returns true if the tags are * successfully stripped. @@ -309,81 +315,81 @@ namespace TagLib { * * \note This will update the file immediately. */ - // BIC: merge with the method above - bool strip(int tags, bool freeMemory); + // BIC: merge with the method above + bool strip(int tags, bool freeMemory); - /*! + /*! * Set the ID3v2::FrameFactory to something other than the default. * * \see ID3v2FrameFactory * \deprecated This value should be passed in via the constructor */ - TAGLIB_DEPRECATED void setID3v2FrameFactory(const ID3v2::FrameFactory *factory); + TAGLIB_DEPRECATED void setID3v2FrameFactory(const ID3v2::FrameFactory *factory); - /*! + /*! * Returns the position in the file of the first MPEG frame. */ - long firstFrameOffset(); + long firstFrameOffset(); - /*! + /*! * Returns the position in the file of the next MPEG frame, * using the current position as start */ - long nextFrameOffset(long position); + long nextFrameOffset(long position); - /*! + /*! * Returns the position in the file of the previous MPEG frame, * using the current position as start */ - long previousFrameOffset(long position); + long previousFrameOffset(long position); - /*! + /*! * Returns the position in the file of the last MPEG frame. */ - long lastFrameOffset(); + long lastFrameOffset(); - /*! + /*! * Returns whether or not the file on disk actually has an ID3v1 tag. * * \see ID3v1Tag() */ - bool hasID3v1Tag() const; + bool hasID3v1Tag() const; - /*! + /*! * Returns whether or not the file on disk actually has an ID3v2 tag. * * \see ID3v2Tag() */ - bool hasID3v2Tag() const; + bool hasID3v2Tag() const; - /*! + /*! * Returns whether or not the file on disk actually has an APE tag. * * \see APETag() */ - bool hasAPETag() const; + bool hasAPETag() const; - /*! + /*! * Returns whether or not the given \a stream can be opened as an MPEG * file. * * \note This method is designed to do a quick check. The result may * not necessarily be correct. */ - static bool isSupported(IOStream *stream); + static bool isSupported(IOStream *stream); - private: - File(const File &); - File &operator=(const File &); + private: + File(const File &); + File &operator=(const File &); - void read(bool readProperties); - long findID3v2(); + void read(bool readProperties); + long findID3v2(); - class FilePrivate; - FilePrivate *d; - }; - } -} -} + class FilePrivate; + FilePrivate *d; +}; +} // namespace MPEG +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/mpegheader.cpp b/3rdparty/taglib/mpeg/mpegheader.cpp index 9171d707d..caaa97776 100644 --- a/3rdparty/taglib/mpeg/mpegheader.cpp +++ b/3rdparty/taglib/mpeg/mpegheader.cpp @@ -34,22 +34,20 @@ using namespace Strawberry_TagLib::TagLib; -class MPEG::Header::HeaderPrivate : public RefCounter -{ -public: - HeaderPrivate() : - isValid(false), - version(Version1), - layer(0), - protectionEnabled(false), - bitrate(0), - sampleRate(0), - isPadded(false), - channelMode(Stereo), - isCopyrighted(false), - isOriginal(false), - frameLength(0), - samplesPerFrame(0) {} +class MPEG::Header::HeaderPrivate : public RefCounter { + public: + HeaderPrivate() : isValid(false), + version(Version1), + layer(0), + protectionEnabled(false), + bitrate(0), + sampleRate(0), + isPadded(false), + channelMode(Stereo), + isCopyrighted(false), + isOriginal(false), + frameLength(0), + samplesPerFrame(0) {} bool isValid; Version version; @@ -69,96 +67,76 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -MPEG::Header::Header(const ByteVector&) : - d(new HeaderPrivate()) -{ +MPEG::Header::Header(const ByteVector &) : d(new HeaderPrivate()) { debug("MPEG::Header::Header() - This constructor is no longer used."); } -MPEG::Header::Header(File *file, long offset, bool checkLength) : - d(new HeaderPrivate()) -{ +MPEG::Header::Header(File *file, long offset, bool checkLength) : d(new HeaderPrivate()) { parse(file, offset, checkLength); } -MPEG::Header::Header(const Header &h) : - d(h.d) -{ +MPEG::Header::Header(const Header &h) : d(h.d) { d->ref(); } -MPEG::Header::~Header() -{ - if(d->deref()) +MPEG::Header::~Header() { + if (d->deref()) delete d; } -bool MPEG::Header::isValid() const -{ +bool MPEG::Header::isValid() const { return d->isValid; } -MPEG::Header::Version MPEG::Header::version() const -{ +MPEG::Header::Version MPEG::Header::version() const { return d->version; } -int MPEG::Header::layer() const -{ +int MPEG::Header::layer() const { return d->layer; } -bool MPEG::Header::protectionEnabled() const -{ +bool MPEG::Header::protectionEnabled() const { return d->protectionEnabled; } -int MPEG::Header::bitrate() const -{ +int MPEG::Header::bitrate() const { return d->bitrate; } -int MPEG::Header::sampleRate() const -{ +int MPEG::Header::sampleRate() const { return d->sampleRate; } -bool MPEG::Header::isPadded() const -{ +bool MPEG::Header::isPadded() const { return d->isPadded; } -MPEG::Header::ChannelMode MPEG::Header::channelMode() const -{ +MPEG::Header::ChannelMode MPEG::Header::channelMode() const { return d->channelMode; } -bool MPEG::Header::isCopyrighted() const -{ +bool MPEG::Header::isCopyrighted() const { return d->isCopyrighted; } -bool MPEG::Header::isOriginal() const -{ +bool MPEG::Header::isOriginal() const { return d->isOriginal; } -int MPEG::Header::frameLength() const -{ +int MPEG::Header::frameLength() const { return d->frameLength; } -int MPEG::Header::samplesPerFrame() const -{ +int MPEG::Header::samplesPerFrame() const { return d->samplesPerFrame; } -MPEG::Header &MPEG::Header::operator=(const Header &h) -{ - if(&h == this) +MPEG::Header &MPEG::Header::operator=(const Header &h) { + if (&h == this) return *this; - if(d->deref()) + if (d->deref()) delete d; d = h.d; @@ -170,19 +148,18 @@ MPEG::Header &MPEG::Header::operator=(const Header &h) // private members //////////////////////////////////////////////////////////////////////////////// -void MPEG::Header::parse(File *file, long offset, bool checkLength) -{ +void MPEG::Header::parse(File *file, long offset, bool checkLength) { file->seek(offset); const ByteVector data = file->readBlock(4); - if(data.size() < 4) { + if (data.size() < 4) { debug("MPEG::Header::parse() -- data is too short for an MPEG frame header."); return; } // Check for the MPEG synch bytes. - if(!isFrameSync(data)) { + if (!isFrameSync(data)) { debug("MPEG::Header::parse() -- MPEG header did not match MPEG synch."); return; } @@ -191,11 +168,11 @@ void MPEG::Header::parse(File *file, long offset, bool checkLength) const int versionBits = (static_cast(data[1]) >> 3) & 0x03; - if(versionBits == 0) + if (versionBits == 0) d->version = Version2_5; - else if(versionBits == 2) + else if (versionBits == 2) d->version = Version2; - else if(versionBits == 3) + else if (versionBits == 3) d->version = Version1; else return; @@ -204,11 +181,11 @@ void MPEG::Header::parse(File *file, long offset, bool checkLength) const int layerBits = (static_cast(data[1]) >> 1) & 0x03; - if(layerBits == 1) + if (layerBits == 1) d->layer = 3; - else if(layerBits == 2) + else if (layerBits == 2) d->layer = 2; - else if(layerBits == 3) + else if (layerBits == 3) d->layer = 1; else return; @@ -218,20 +195,22 @@ void MPEG::Header::parse(File *file, long offset, bool checkLength) // Set the bitrate static const int bitrates[2][3][16] = { - { // Version 1 - { 0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 0 }, // layer 1 - { 0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 0 }, // layer 2 - { 0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 0 } // layer 3 + { + // Version 1 + { 0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 0 }, // layer 1 + { 0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 0 }, // layer 2 + { 0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 0 } // layer 3 }, - { // Version 2 or 2.5 - { 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, 0 }, // layer 1 - { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0 }, // layer 2 - { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0 } // layer 3 + { + // Version 2 or 2.5 + { 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, 0 }, // layer 1 + { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0 }, // layer 2 + { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0 } // layer 3 } }; const int versionIndex = (d->version == Version1) ? 0 : 1; - const int layerIndex = (d->layer > 0) ? d->layer - 1 : 0; + const int layerIndex = (d->layer > 0) ? d->layer - 1 : 0; // The bitrate index is encoded as the first 4 bits of the 3rd byte, // i.e. 1111xxxx @@ -240,15 +219,15 @@ void MPEG::Header::parse(File *file, long offset, bool checkLength) d->bitrate = bitrates[versionIndex][layerIndex][bitrateIndex]; - if(d->bitrate == 0) + if (d->bitrate == 0) return; // Set the sample rate static const int sampleRates[3][4] = { - { 44100, 48000, 32000, 0 }, // Version 1 - { 22050, 24000, 16000, 0 }, // Version 2 - { 11025, 12000, 8000, 0 } // Version 2.5 + { 44100, 48000, 32000, 0 }, // Version 1 + { 22050, 24000, 16000, 0 }, // Version 2 + { 11025, 12000, 8000, 0 } // Version 2.5 }; // The sample rate index is encoded as two bits in the 3nd byte, i.e. xxxx11xx @@ -257,7 +236,7 @@ void MPEG::Header::parse(File *file, long offset, bool checkLength) d->sampleRate = sampleRates[d->version][samplerateIndex]; - if(d->sampleRate == 0) { + if (d->sampleRate == 0) { return; } @@ -268,17 +247,17 @@ void MPEG::Header::parse(File *file, long offset, bool checkLength) // TODO: Add mode extension for completeness - d->isOriginal = ((static_cast(data[3]) & 0x04) != 0); + d->isOriginal = ((static_cast(data[3]) & 0x04) != 0); d->isCopyrighted = ((static_cast(data[3]) & 0x08) != 0); - d->isPadded = ((static_cast(data[2]) & 0x02) != 0); + d->isPadded = ((static_cast(data[2]) & 0x02) != 0); // Samples per frame static const int samplesPerFrame[3][2] = { // MPEG1, 2/2.5 - { 384, 384 }, // Layer I - { 1152, 1152 }, // Layer II - { 1152, 576 } // Layer III + { 384, 384 }, // Layer I + { 1152, 1152 }, // Layer II + { 1152, 576 } // Layer III }; d->samplesPerFrame = samplesPerFrame[layerIndex][versionIndex]; @@ -289,10 +268,10 @@ void MPEG::Header::parse(File *file, long offset, bool checkLength) d->frameLength = d->samplesPerFrame * d->bitrate * 125 / d->sampleRate; - if(d->isPadded) + if (d->isPadded) d->frameLength += paddingSize[layerIndex]; - if(checkLength) { + if (checkLength) { // Check if the frame length has been calculated correctly, or the next frame // header is right next to the end of this frame. @@ -304,15 +283,15 @@ void MPEG::Header::parse(File *file, long offset, bool checkLength) file->seek(offset + d->frameLength); const ByteVector nextData = file->readBlock(4); - if(nextData.size() < 4) + if (nextData.size() < 4) return; const unsigned int HeaderMask = 0xfffe0c00; - const unsigned int header = data.toUInt(0, true) & HeaderMask; + const unsigned int header = data.toUInt(0, true) & HeaderMask; const unsigned int nextHeader = nextData.toUInt(0, true) & HeaderMask; - if(header != nextHeader) + if (header != nextHeader) return; } diff --git a/3rdparty/taglib/mpeg/mpegheader.h b/3rdparty/taglib/mpeg/mpegheader.h index 8db0f705d..9a0b7e387 100644 --- a/3rdparty/taglib/mpeg/mpegheader.h +++ b/3rdparty/taglib/mpeg/mpegheader.h @@ -31,150 +31,149 @@ namespace Strawberry_TagLib { namespace TagLib { - class ByteVector; - class File; +class ByteVector; +class File; - namespace MPEG { +namespace MPEG { - //! An implementation of MP3 frame headers +//! An implementation of MP3 frame headers - /*! +/*! * This is an implementation of MPEG Layer III headers. The API follows more * or less the binary format of these headers. I've used * this * document as a reference. */ - class TAGLIB_EXPORT Header - { - public: - /*! +class TAGLIB_EXPORT Header { + public: + /*! * Parses an MPEG header based on \a data. * * \deprecated */ - TAGLIB_DEPRECATED Header(const ByteVector &data); + TAGLIB_DEPRECATED Header(const ByteVector &data); - /*! + /*! * Parses an MPEG header based on \a file and \a offset. * * \note If \a checkLength is true, this requires the next MPEG frame to * check if the frame length is parsed and calculated correctly. So it's * suitable for seeking for the first valid frame. */ - Header(File *file, long offset, bool checkLength = true); + Header(File *file, long offset, bool checkLength = true); - /*! + /*! * Does a shallow copy of \a h. */ - Header(const Header &h); + Header(const Header &h); - /*! + /*! * Destroys this Header instance. */ - virtual ~Header(); + virtual ~Header(); - /*! + /*! * Returns true if the frame is at least an appropriate size and has * legal values. */ - bool isValid() const; + bool isValid() const; - /*! + /*! * The MPEG Version. */ - enum Version { - //! MPEG Version 1 - Version1 = 0, - //! MPEG Version 2 - Version2 = 1, - //! MPEG Version 2.5 - Version2_5 = 2 - }; + enum Version { + //! MPEG Version 1 + Version1 = 0, + //! MPEG Version 2 + Version2 = 1, + //! MPEG Version 2.5 + Version2_5 = 2 + }; - /*! + /*! * Returns the MPEG Version of the header. */ - Version version() const; + Version version() const; - /*! + /*! * Returns the layer version. This will be between the values 1-3. */ - int layer() const; + int layer() const; - /*! + /*! * Returns true if the MPEG protection bit is enabled. */ - bool protectionEnabled() const; + bool protectionEnabled() const; - /*! + /*! * Returns the bitrate encoded in the header. */ - int bitrate() const; + int bitrate() const; - /*! + /*! * Returns the sample rate in Hz. */ - int sampleRate() const; + int sampleRate() const; - /*! + /*! * Returns true if the frame is padded. */ - bool isPadded() const; + bool isPadded() const; - /*! + /*! * There are a few combinations or one or two channel audio that are * possible: */ - enum ChannelMode { - //! Stereo - Stereo = 0, - //! Stereo - JointStereo = 1, - //! Dual Mono - DualChannel = 2, - //! Mono - SingleChannel = 3 - }; + enum ChannelMode { + //! Stereo + Stereo = 0, + //! Stereo + JointStereo = 1, + //! Dual Mono + DualChannel = 2, + //! Mono + SingleChannel = 3 + }; - /*! + /*! * Returns the channel mode for this frame. */ - ChannelMode channelMode() const; + ChannelMode channelMode() const; - /*! + /*! * Returns true if the copyrighted bit is set. */ - bool isCopyrighted() const; + bool isCopyrighted() const; - /*! + /*! * Returns true if the "original" bit is set. */ - bool isOriginal() const; + bool isOriginal() const; - /*! + /*! * Returns the frame length in bytes. */ - int frameLength() const; + int frameLength() const; - /*! + /*! * Returns the number of frames per sample. */ - int samplesPerFrame() const; + int samplesPerFrame() const; - /*! + /*! * Makes a shallow copy of the header. */ - Header &operator=(const Header &h); + Header &operator=(const Header &h); - private: - void parse(File *file, long offset, bool checkLength); + private: + void parse(File *file, long offset, bool checkLength); - class HeaderPrivate; - HeaderPrivate *d; - }; - } -} -} + class HeaderPrivate; + HeaderPrivate *d; +}; +} // namespace MPEG +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/mpegproperties.cpp b/3rdparty/taglib/mpeg/mpegproperties.cpp index 933fa0953..425e80a75 100644 --- a/3rdparty/taglib/mpeg/mpegproperties.cpp +++ b/3rdparty/taglib/mpeg/mpegproperties.cpp @@ -34,24 +34,21 @@ using namespace Strawberry_TagLib::TagLib; -class MPEG::Properties::PropertiesPrivate -{ -public: - PropertiesPrivate() : - xingHeader(0), - length(0), - bitrate(0), - sampleRate(0), - channels(0), - layer(0), - version(Header::Version1), - channelMode(Header::Stereo), - protectionEnabled(false), - isCopyrighted(false), - isOriginal(false) {} +class MPEG::Properties::PropertiesPrivate { + public: + PropertiesPrivate() : xingHeader(0), + length(0), + bitrate(0), + sampleRate(0), + channels(0), + layer(0), + version(Header::Version1), + channelMode(Header::Stereo), + protectionEnabled(false), + isCopyrighted(false), + isOriginal(false) {} - ~PropertiesPrivate() - { + ~PropertiesPrivate() { delete xingHeader; } @@ -72,80 +69,64 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -MPEG::Properties::Properties(File *file, ReadStyle style) : - AudioProperties(style), - d(new PropertiesPrivate()) -{ +MPEG::Properties::Properties(File *file, ReadStyle style) : AudioProperties(style), + d(new PropertiesPrivate()) { read(file); } -MPEG::Properties::~Properties() -{ +MPEG::Properties::~Properties() { delete d; } -int MPEG::Properties::length() const -{ +int MPEG::Properties::length() const { return lengthInSeconds(); } -int MPEG::Properties::lengthInSeconds() const -{ +int MPEG::Properties::lengthInSeconds() const { return d->length / 1000; } -int MPEG::Properties::lengthInMilliseconds() const -{ +int MPEG::Properties::lengthInMilliseconds() const { return d->length; } -int MPEG::Properties::bitrate() const -{ +int MPEG::Properties::bitrate() const { return d->bitrate; } -int MPEG::Properties::sampleRate() const -{ +int MPEG::Properties::sampleRate() const { return d->sampleRate; } -int MPEG::Properties::channels() const -{ +int MPEG::Properties::channels() const { return d->channels; } -const MPEG::XingHeader *MPEG::Properties::xingHeader() const -{ +const MPEG::XingHeader *MPEG::Properties::xingHeader() const { return d->xingHeader; } -MPEG::Header::Version MPEG::Properties::version() const -{ +MPEG::Header::Version MPEG::Properties::version() const { return d->version; } -int MPEG::Properties::layer() const -{ +int MPEG::Properties::layer() const { return d->layer; } -bool MPEG::Properties::protectionEnabled() const -{ +bool MPEG::Properties::protectionEnabled() const { return d->protectionEnabled; } -MPEG::Header::ChannelMode MPEG::Properties::channelMode() const -{ +MPEG::Header::ChannelMode MPEG::Properties::channelMode() const { return d->channelMode; } -bool MPEG::Properties::isCopyrighted() const -{ +bool MPEG::Properties::isCopyrighted() const { return d->isCopyrighted; } -bool MPEG::Properties::isOriginal() const -{ +bool MPEG::Properties::isOriginal() const { return d->isOriginal; } @@ -153,12 +134,11 @@ bool MPEG::Properties::isOriginal() const // private members //////////////////////////////////////////////////////////////////////////////// -void MPEG::Properties::read(File *file) -{ +void MPEG::Properties::read(File *file) { // Only the first valid frame is required if we have a VBR header. const long firstFrameOffset = file->firstFrameOffset(); - if(firstFrameOffset < 0) { + if (firstFrameOffset < 0) { debug("MPEG::Properties::read() -- Could not find an MPEG frame in the stream."); return; } @@ -170,22 +150,22 @@ void MPEG::Properties::read(File *file) file->seek(firstFrameOffset); d->xingHeader = new XingHeader(file->readBlock(firstHeader.frameLength())); - if(!d->xingHeader->isValid()) { + if (!d->xingHeader->isValid()) { delete d->xingHeader; d->xingHeader = 0; } - if(d->xingHeader && firstHeader.samplesPerFrame() > 0 && firstHeader.sampleRate() > 0) { + if (d->xingHeader && firstHeader.samplesPerFrame() > 0 && firstHeader.sampleRate() > 0) { // Read the length and the bitrate from the VBR header. const double timePerFrame = firstHeader.samplesPerFrame() * 1000.0 / firstHeader.sampleRate(); const double length = timePerFrame * d->xingHeader->totalFrames(); - d->length = static_cast(length + 0.5); + d->length = static_cast(length + 0.5); d->bitrate = static_cast(d->xingHeader->totalSize() * 8.0 / length + 0.5); } - else if(firstHeader.bitrate() > 0) { + else if (firstHeader.bitrate() > 0) { // Since there was no valid VBR header found, we hope that we're in a constant // bitrate file. @@ -198,23 +178,23 @@ void MPEG::Properties::read(File *file) // Look for the last MPEG audio frame to calculate the stream length. const long lastFrameOffset = file->lastFrameOffset(); - if(lastFrameOffset < 0) { + if (lastFrameOffset < 0) { debug("MPEG::Properties::read() -- Could not find an MPEG frame in the stream."); return; } const Header lastHeader(file, lastFrameOffset, false); const long streamLength = lastFrameOffset - firstFrameOffset + lastHeader.frameLength(); - if(streamLength > 0) + if (streamLength > 0) d->length = static_cast(streamLength * 8.0 / d->bitrate + 0.5); } - d->sampleRate = firstHeader.sampleRate(); - d->channels = firstHeader.channelMode() == Header::SingleChannel ? 1 : 2; - d->version = firstHeader.version(); - d->layer = firstHeader.layer(); + d->sampleRate = firstHeader.sampleRate(); + d->channels = firstHeader.channelMode() == Header::SingleChannel ? 1 : 2; + d->version = firstHeader.version(); + d->layer = firstHeader.layer(); d->protectionEnabled = firstHeader.protectionEnabled(); - d->channelMode = firstHeader.channelMode(); - d->isCopyrighted = firstHeader.isCopyrighted(); - d->isOriginal = firstHeader.isOriginal(); + d->channelMode = firstHeader.channelMode(); + d->isCopyrighted = firstHeader.isCopyrighted(); + d->isOriginal = firstHeader.isOriginal(); } diff --git a/3rdparty/taglib/mpeg/mpegproperties.h b/3rdparty/taglib/mpeg/mpegproperties.h index 48c8aa620..39de90743 100644 --- a/3rdparty/taglib/mpeg/mpegproperties.h +++ b/3rdparty/taglib/mpeg/mpegproperties.h @@ -34,33 +34,32 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace MPEG { +namespace MPEG { - class File; - class XingHeader; +class File; +class XingHeader; - //! An implementation of audio property reading for MP3 +//! An implementation of audio property reading for MP3 - /*! +/*! * This reads the data from an MPEG Layer III stream found in the * AudioProperties API. */ - class TAGLIB_EXPORT Properties : public AudioProperties - { - public: - /*! +class TAGLIB_EXPORT Properties : public AudioProperties { + public: + /*! * Create an instance of MPEG::Properties with the data read from the * MPEG::File \a file. */ - Properties(File *file, ReadStyle style = Average); + Properties(File *file, ReadStyle style = Average); - /*! + /*! * Destroys this MPEG Properties instance. */ - virtual ~Properties(); + virtual ~Properties(); - /*! + /*! * Returns the length of the file in seconds. The length is rounded down to * the nearest whole second. * @@ -68,87 +67,87 @@ namespace TagLib { * * \deprecated */ - virtual int length() const; + virtual int length() const; - /*! + /*! * Returns the length of the file in seconds. The length is rounded down to * the nearest whole second. * * \see lengthInMilliseconds() */ - // BIC: make virtual - int lengthInSeconds() const; + // BIC: make virtual + int lengthInSeconds() const; - /*! + /*! * Returns the length of the file in milliseconds. * * \see lengthInSeconds() */ - // BIC: make virtual - int lengthInMilliseconds() const; + // BIC: make virtual + int lengthInMilliseconds() const; - /*! + /*! * Returns the average bit rate of the file in kb/s. */ - virtual int bitrate() const; + virtual int bitrate() const; - /*! + /*! * Returns the sample rate in Hz. */ - virtual int sampleRate() const; + virtual int sampleRate() const; - /*! + /*! * Returns the number of audio channels. */ - virtual int channels() const; + virtual int channels() const; - /*! + /*! * Returns a pointer to the Xing/VBRI header if one exists or null if no * Xing/VBRI header was found. */ - const XingHeader *xingHeader() const; + const XingHeader *xingHeader() const; - /*! + /*! * Returns the MPEG Version of the file. */ - Header::Version version() const; + Header::Version version() const; - /*! + /*! * Returns the layer version. This will be between the values 1-3. */ - int layer() const; + int layer() const; - /*! + /*! * Returns true if the MPEG protection bit is enabled. */ - bool protectionEnabled() const; + bool protectionEnabled() const; - /*! + /*! * Returns the channel mode for this frame. */ - Header::ChannelMode channelMode() const; + Header::ChannelMode channelMode() const; - /*! + /*! * Returns true if the copyrighted bit is set. */ - bool isCopyrighted() const; + bool isCopyrighted() const; - /*! + /*! * Returns true if the "original" bit is set. */ - bool isOriginal() const; + bool isOriginal() const; - private: - Properties(const Properties &); - Properties &operator=(const Properties &); + private: + Properties(const Properties &); + Properties &operator=(const Properties &); - void read(File *file); + void read(File *file); - class PropertiesPrivate; - PropertiesPrivate *d; - }; - } -} -} + class PropertiesPrivate; + PropertiesPrivate *d; +}; +} // namespace MPEG +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/mpegutils.h b/3rdparty/taglib/mpeg/mpegutils.h index 60a70bea6..29cbd4ea0 100644 --- a/3rdparty/taglib/mpeg/mpegutils.h +++ b/3rdparty/taglib/mpeg/mpegutils.h @@ -31,14 +31,11 @@ #ifndef DO_NOT_DOCUMENT // tell Doxygen not to document this header namespace Strawberry_TagLib { -namespace TagLib -{ - namespace MPEG - { - namespace - { +namespace TagLib { +namespace MPEG { +namespace { - /*! +/*! * MPEG frames can be recognized by the bit pattern 11111111 111, so the * first byte is easy to check for, however checking to see if the second byte * starts with \e 111 is a bit more tricky, hence these functions. @@ -46,19 +43,18 @@ namespace TagLib * \note This does not check the length of the vector, since this is an * internal utility function. */ - inline bool isFrameSync(const ByteVector &bytes, unsigned int offset = 0) - { - // 0xFF in the second byte is possible in theory, but it's very unlikely. +inline bool isFrameSync(const ByteVector &bytes, unsigned int offset = 0) { + // 0xFF in the second byte is possible in theory, but it's very unlikely. - const unsigned char b1 = bytes[offset + 0]; - const unsigned char b2 = bytes[offset + 1]; - return (b1 == 0xFF && b2 != 0xFF && (b2 & 0xE0) == 0xE0); - } + const unsigned char b1 = bytes[offset + 0]; + const unsigned char b2 = bytes[offset + 1]; + return (b1 == 0xFF && b2 != 0xFF && (b2 & 0xE0) == 0xE0); +} - } - } -} -} +} // namespace +} // namespace MPEG +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/mpeg/xingheader.cpp b/3rdparty/taglib/mpeg/xingheader.cpp index fc794025d..ba6de9a77 100644 --- a/3rdparty/taglib/mpeg/xingheader.cpp +++ b/3rdparty/taglib/mpeg/xingheader.cpp @@ -32,13 +32,11 @@ using namespace Strawberry_TagLib::TagLib; -class MPEG::XingHeader::XingHeaderPrivate -{ -public: - XingHeaderPrivate() : - frames(0), - size(0), - type(MPEG::XingHeader::Invalid) {} +class MPEG::XingHeader::XingHeaderPrivate { + public: + XingHeaderPrivate() : frames(0), + size(0), + type(MPEG::XingHeader::Invalid) {} unsigned int frames; unsigned int size; @@ -50,40 +48,32 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -MPEG::XingHeader::XingHeader(const ByteVector &data) : - d(new XingHeaderPrivate()) -{ +MPEG::XingHeader::XingHeader(const ByteVector &data) : d(new XingHeaderPrivate()) { parse(data); } -MPEG::XingHeader::~XingHeader() -{ +MPEG::XingHeader::~XingHeader() { delete d; } -bool MPEG::XingHeader::isValid() const -{ +bool MPEG::XingHeader::isValid() const { return (d->type != Invalid && d->frames > 0 && d->size > 0); } -unsigned int MPEG::XingHeader::totalFrames() const -{ +unsigned int MPEG::XingHeader::totalFrames() const { return d->frames; } -unsigned int MPEG::XingHeader::totalSize() const -{ +unsigned int MPEG::XingHeader::totalSize() const { return d->size; } -MPEG::XingHeader::HeaderType MPEG::XingHeader::type() const -{ +MPEG::XingHeader::HeaderType MPEG::XingHeader::type() const { return d->type; } int MPEG::XingHeader::xingHeaderOffset(Strawberry_TagLib::TagLib::MPEG::Header::Version /*v*/, - Strawberry_TagLib::TagLib::MPEG::Header::ChannelMode /*c*/) -{ + Strawberry_TagLib::TagLib::MPEG::Header::ChannelMode /*c*/) { return 0; } @@ -91,31 +81,30 @@ int MPEG::XingHeader::xingHeaderOffset(Strawberry_TagLib::TagLib::MPEG::Header:: // private members //////////////////////////////////////////////////////////////////////////////// -void MPEG::XingHeader::parse(const ByteVector &data) -{ +void MPEG::XingHeader::parse(const ByteVector &data) { // Look for a Xing header. long offset = data.find("Xing"); - if(offset < 0) + if (offset < 0) offset = data.find("Info"); - if(offset >= 0) { + if (offset >= 0) { // Xing header found. - if(data.size() < static_cast(offset + 16)) { + if (data.size() < static_cast(offset + 16)) { debug("MPEG::XingHeader::parse() -- Xing header found but too short."); return; } - if((data[offset + 7] & 0x03) != 0x03) { + if ((data[offset + 7] & 0x03) != 0x03) { debug("MPEG::XingHeader::parse() -- Xing header doesn't contain the required information."); return; } - d->frames = data.toUInt(offset + 8, true); - d->size = data.toUInt(offset + 12, true); - d->type = Xing; + d->frames = data.toUInt(offset + 8, true); + d->size = data.toUInt(offset + 12, true); + d->type = Xing; } else { @@ -123,18 +112,18 @@ void MPEG::XingHeader::parse(const ByteVector &data) offset = data.find("VBRI"); - if(offset >= 0) { + if (offset >= 0) { // VBRI header found. - if(data.size() < static_cast(offset + 32)) { + if (data.size() < static_cast(offset + 32)) { debug("MPEG::XingHeader::parse() -- VBRI header found but too short."); return; } d->frames = data.toUInt(offset + 14, true); - d->size = data.toUInt(offset + 10, true); - d->type = VBRI; + d->size = data.toUInt(offset + 10, true); + d->type = VBRI; } } } diff --git a/3rdparty/taglib/mpeg/xingheader.h b/3rdparty/taglib/mpeg/xingheader.h index 05128b19e..9bfa6c7bc 100644 --- a/3rdparty/taglib/mpeg/xingheader.h +++ b/3rdparty/taglib/mpeg/xingheader.h @@ -32,15 +32,15 @@ namespace Strawberry_TagLib { namespace TagLib { - class ByteVector; +class ByteVector; - namespace MPEG { +namespace MPEG { - class File; +class File; - //! An implementation of the Xing/VBRI headers +//! An implementation of the Xing/VBRI headers - /*! +/*! * This is a minimalistic implementation of the Xing/VBRI VBR headers. * Xing/VBRI headers are often added to VBR (variable bit rate) MP3 streams * to make it easy to compute the length and quality of a VBR stream. Our @@ -50,82 +50,80 @@ namespace TagLib { * this text and the XMMS sources as references. */ - class TAGLIB_EXPORT XingHeader - { - public: - /*! +class TAGLIB_EXPORT XingHeader { + public: + /*! * The type of the VBR header. */ - enum HeaderType - { - /*! + enum HeaderType { + /*! * Invalid header or no VBR header found. */ - Invalid = 0, + Invalid = 0, - /*! + /*! * Xing header. */ - Xing = 1, + Xing = 1, - /*! + /*! * VBRI header. */ - VBRI = 2, - }; + VBRI = 2, + }; - /*! + /*! * Parses an Xing/VBRI header based on \a data which contains the entire * first MPEG frame. */ - XingHeader(const ByteVector &data); + XingHeader(const ByteVector &data); - /*! + /*! * Destroy this XingHeader instance. */ - virtual ~XingHeader(); + virtual ~XingHeader(); - /*! + /*! * Returns true if the data was parsed properly and if there is a valid * Xing/VBRI header present. */ - bool isValid() const; + bool isValid() const; - /*! + /*! * Returns the total number of frames. */ - unsigned int totalFrames() const; + unsigned int totalFrames() const; - /*! + /*! * Returns the total size of stream in bytes. */ - unsigned int totalSize() const; + unsigned int totalSize() const; - /*! + /*! * Returns the type of the VBR header. */ - HeaderType type() const; + HeaderType type() const; - /*! + /*! * Returns the offset for the start of this Xing header, given the * version and channels of the frame * * \deprecated Always returns 0. */ - TAGLIB_DEPRECATED static int xingHeaderOffset(Strawberry_TagLib::TagLib::MPEG::Header::Version v, - Strawberry_TagLib::TagLib::MPEG::Header::ChannelMode c); + TAGLIB_DEPRECATED static int xingHeaderOffset(Strawberry_TagLib::TagLib::MPEG::Header::Version v, + Strawberry_TagLib::TagLib::MPEG::Header::ChannelMode c); - private: - XingHeader(const XingHeader &); - XingHeader &operator=(const XingHeader &); + private: + XingHeader(const XingHeader &); + XingHeader &operator=(const XingHeader &); - void parse(const ByteVector &data); + void parse(const ByteVector &data); - class XingHeaderPrivate; - XingHeaderPrivate *d; - }; - } -} -} + class XingHeaderPrivate; + XingHeaderPrivate *d; +}; +} // namespace MPEG +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/ogg/flac/oggflacfile.cpp b/3rdparty/taglib/ogg/flac/oggflacfile.cpp index b0387e819..ddc88ca70 100644 --- a/3rdparty/taglib/ogg/flac/oggflacfile.cpp +++ b/3rdparty/taglib/ogg/flac/oggflacfile.cpp @@ -35,20 +35,17 @@ using namespace Strawberry_TagLib::TagLib; using Strawberry_TagLib::TagLib::FLAC::Properties; -class Ogg::FLAC::File::FilePrivate -{ -public: - FilePrivate() : - comment(0), - properties(0), - streamStart(0), - streamLength(0), - scanned(false), - hasXiphComment(false), - commentPacket(0) {} +class Ogg::FLAC::File::FilePrivate { + public: + FilePrivate() : comment(0), + properties(0), + streamStart(0), + streamLength(0), + scanned(false), + hasXiphComment(false), + commentPacket(0) {} - ~FilePrivate() - { + ~FilePrivate() { delete comment; delete properties; } @@ -70,8 +67,7 @@ public: // static members //////////////////////////////////////////////////////////////////////////////// -bool Ogg::FLAC::File::isSupported(IOStream *stream) -{ +bool Ogg::FLAC::File::isSupported(IOStream *stream) { // An Ogg FLAC file has IDs "OggS" and "fLaC" somewhere. const ByteVector buffer = Utils::readHeader(stream, bufferSize(), false); @@ -83,51 +79,41 @@ bool Ogg::FLAC::File::isSupported(IOStream *stream) //////////////////////////////////////////////////////////////////////////////// Ogg::FLAC::File::File(FileName file, bool readProperties, - Properties::ReadStyle propertiesStyle) : - Ogg::File(file), - d(new FilePrivate()) -{ - if(isOpen()) + Properties::ReadStyle propertiesStyle) : Ogg::File(file), + d(new FilePrivate()) { + if (isOpen()) read(readProperties, propertiesStyle); } Ogg::FLAC::File::File(IOStream *stream, bool readProperties, - Properties::ReadStyle propertiesStyle) : - Ogg::File(stream), - d(new FilePrivate()) -{ - if(isOpen()) + Properties::ReadStyle propertiesStyle) : Ogg::File(stream), + d(new FilePrivate()) { + if (isOpen()) read(readProperties, propertiesStyle); } -Ogg::FLAC::File::~File() -{ +Ogg::FLAC::File::~File() { delete d; } -Ogg::XiphComment *Ogg::FLAC::File::tag() const -{ +Ogg::XiphComment *Ogg::FLAC::File::tag() const { return d->comment; } -PropertyMap Ogg::FLAC::File::properties() const -{ +PropertyMap Ogg::FLAC::File::properties() const { return d->comment->properties(); } -PropertyMap Ogg::FLAC::File::setProperties(const PropertyMap &properties) -{ +PropertyMap Ogg::FLAC::File::setProperties(const PropertyMap &properties) { return d->comment->setProperties(properties); } -Properties *Ogg::FLAC::File::audioProperties() const -{ +Properties *Ogg::FLAC::File::audioProperties() const { return d->properties; } -bool Ogg::FLAC::File::save() -{ +bool Ogg::FLAC::File::save() { d->xiphCommentData = d->comment->render(false); // Create FLAC metadata-block: @@ -152,8 +138,7 @@ bool Ogg::FLAC::File::save() return Ogg::File::save(); } -bool Ogg::FLAC::File::hasXiphComment() const -{ +bool Ogg::FLAC::File::hasXiphComment() const { return d->hasXiphComment; } @@ -161,11 +146,10 @@ bool Ogg::FLAC::File::hasXiphComment() const // private members //////////////////////////////////////////////////////////////////////////////// -void Ogg::FLAC::File::read(bool readProperties, Properties::ReadStyle propertiesStyle) -{ +void Ogg::FLAC::File::read(bool readProperties, Properties::ReadStyle propertiesStyle) { // Sanity: Check if we really have an Ogg/FLAC file -/* + /* ByteVector oggHeader = packet(0); if (oggHeader.mid(28,4) != "fLaC") { @@ -184,67 +168,63 @@ void Ogg::FLAC::File::read(bool readProperties, Properties::ReadStyle properties } - if(d->hasXiphComment) + if (d->hasXiphComment) d->comment = new Ogg::XiphComment(xiphCommentData()); else d->comment = new Ogg::XiphComment(); - if(readProperties) + if (readProperties) d->properties = new Properties(streamInfoData(), streamLength(), propertiesStyle); } -ByteVector Ogg::FLAC::File::streamInfoData() -{ +ByteVector Ogg::FLAC::File::streamInfoData() { scan(); return d->streamInfoData; } -ByteVector Ogg::FLAC::File::xiphCommentData() -{ +ByteVector Ogg::FLAC::File::xiphCommentData() { scan(); return d->xiphCommentData; } -long Ogg::FLAC::File::streamLength() -{ +long Ogg::FLAC::File::streamLength() { scan(); return d->streamLength; } -void Ogg::FLAC::File::scan() -{ +void Ogg::FLAC::File::scan() { // Scan the metadata pages - if(d->scanned) + if (d->scanned) return; - if(!isValid()) + if (!isValid()) return; int ipacket = 0; long overhead = 0; ByteVector metadataHeader = packet(ipacket); - if(metadataHeader.isEmpty()) + if (metadataHeader.isEmpty()) return; - if(!metadataHeader.startsWith("fLaC")) { + if (!metadataHeader.startsWith("fLaC")) { // FLAC 1.1.2+ // See https://xiph.org/flac/ogg_mapping.html for the header specification. - if(metadataHeader.size() < 13) + if (metadataHeader.size() < 13) return; - if(metadataHeader[0] != 0x7f) + if (metadataHeader[0] != 0x7f) return; - if(metadataHeader.mid(1, 4) != "FLAC") + if (metadataHeader.mid(1, 4) != "FLAC") return; - if(metadataHeader[5] != 1 && metadataHeader[6] != 0) - return; // not version 1.0 + if (metadataHeader[5] != 1 && metadataHeader[6] != 0) + return; // not version 1.0 - if(metadataHeader.mid(9, 4) != "fLaC") + if (metadataHeader.mid(9, 4) != "fLaC") return; metadataHeader = metadataHeader.mid(13); @@ -255,7 +235,7 @@ void Ogg::FLAC::File::scan() } ByteVector header = metadataHeader.mid(0, 4); - if(header.size() != 4) { + if (header.size() != 4) { debug("Ogg::FLAC::File::scan() -- Invalid Ogg/FLAC metadata header"); return; } @@ -277,7 +257,7 @@ void Ogg::FLAC::File::scan() // Sanity: First block should be the stream_info metadata - if(blockType != 0) { + if (blockType != 0) { debug("Ogg::FLAC::File::scan() -- Invalid Ogg/FLAC stream"); return; } @@ -286,10 +266,10 @@ void Ogg::FLAC::File::scan() // Search through the remaining metadata - while(!lastBlock) { + while (!lastBlock) { metadataHeader = packet(++ipacket); header = metadataHeader.mid(0, 4); - if(header.size() != 4) { + if (header.size() != 4) { debug("Ogg::FLAC::File::scan() -- Invalid Ogg/FLAC metadata header"); return; } @@ -299,16 +279,16 @@ void Ogg::FLAC::File::scan() length = header.toUInt(1, 3, true); overhead += length; - if(blockType == 1) { + if (blockType == 1) { // debug("Ogg::FLAC::File::scan() -- Padding found"); } - else if(blockType == 4) { + else if (blockType == 4) { // debug("Ogg::FLAC::File::scan() -- Vorbis-comments found"); d->xiphCommentData = metadataHeader.mid(4, length); d->hasXiphComment = true; d->commentPacket = ipacket; } - else if(blockType > 5) { + else if (blockType > 5) { debug("Ogg::FLAC::File::scan() -- Unknown metadata block"); } } diff --git a/3rdparty/taglib/ogg/flac/oggflacfile.h b/3rdparty/taglib/ogg/flac/oggflacfile.h index 149657a6c..71a3222d3 100644 --- a/3rdparty/taglib/ogg/flac/oggflacfile.h +++ b/3rdparty/taglib/ogg/flac/oggflacfile.h @@ -35,45 +35,44 @@ namespace Strawberry_TagLib { namespace TagLib { - class Tag; +class Tag; - namespace Ogg { +namespace Ogg { - //! An implementation of Ogg FLAC metadata +//! An implementation of Ogg FLAC metadata - /*! +/*! * This is implementation of FLAC metadata for Ogg FLAC files. For "pure" * FLAC files look under the FLAC hierarchy. * * Unlike "pure" FLAC-files, Ogg FLAC only supports Xiph-comments, * while the audio-properties are the same. */ - namespace FLAC { +namespace FLAC { - using Strawberry_TagLib::TagLib::FLAC::Properties; +using Strawberry_TagLib::TagLib::FLAC::Properties; - //! An implementation of TagLib::File with Ogg/FLAC specific methods +//! An implementation of TagLib::File with Ogg/FLAC specific methods - /*! +/*! * This implements and provides an interface for Ogg/FLAC files to the * TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing * the abstract TagLib::File API as well as providing some additional * information specific to Ogg FLAC files. */ - class TAGLIB_EXPORT File : public Ogg::File - { - public: - /*! +class TAGLIB_EXPORT File : public Ogg::File { + public: + /*! * Constructs an Ogg/FLAC file from \a file. If \a readProperties is true * the file's audio properties will also be read. * * \note In the current implementation, \a propertiesStyle is ignored. */ - File(FileName file, bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(FileName file, bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Constructs an Ogg/FLAC file from \a stream. If \a readProperties is true * the file's audio properties will also be read. * @@ -82,15 +81,15 @@ namespace TagLib { * * \note In the current implementation, \a propertiesStyle is ignored. */ - File(IOStream *stream, bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(IOStream *stream, bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Destroys this instance of the File. */ - virtual ~File(); + virtual ~File(); - /*! + /*! * Returns the Tag for this file. This will always be a XiphComment. * * \note This always returns a valid pointer regardless of whether or not @@ -103,70 +102,70 @@ namespace TagLib { * * \see hasXiphComment() */ - virtual XiphComment *tag() const; + virtual XiphComment *tag() const; - /*! + /*! * Returns the FLAC::Properties for this file. If no audio properties * were read then this will return a null pointer. */ - virtual Properties *audioProperties() const; + virtual Properties *audioProperties() const; - /*! + /*! * Implements the unified property interface -- export function. * This forwards directly to XiphComment::properties(). */ - PropertyMap properties() const; + PropertyMap properties() const; - /*! + /*! * Implements the unified tag dictionary interface -- import function. * Like properties(), this is a forwarder to the file's XiphComment. */ - PropertyMap setProperties(const PropertyMap &); + PropertyMap setProperties(const PropertyMap &); - /*! + /*! * Save the file. This will primarily save and update the XiphComment. * Returns true if the save is successful. */ - virtual bool save(); + virtual bool save(); - /*! + /*! * Returns the length of the audio-stream, used by FLAC::Properties for * calculating the bitrate. */ - long streamLength(); + long streamLength(); - /*! + /*! * Returns whether or not the file on disk actually has a XiphComment. * * \see tag() */ - bool hasXiphComment() const; + bool hasXiphComment() const; - /*! + /*! * Check if the given \a stream can be opened as an Ogg FLAC file. * * \note This method is designed to do a quick check. The result may * not necessarily be correct. */ - static bool isSupported(IOStream *stream); + static bool isSupported(IOStream *stream); - private: - File(const File &); - File &operator=(const File &); + private: + File(const File &); + File &operator=(const File &); - void read(bool readProperties, Properties::ReadStyle propertiesStyle); - void scan(); - ByteVector streamInfoData(); - ByteVector xiphCommentData(); + void read(bool readProperties, Properties::ReadStyle propertiesStyle); + void scan(); + ByteVector streamInfoData(); + ByteVector xiphCommentData(); - class FilePrivate; - FilePrivate *d; - }; - } // namespace FLAC - } // namespace Ogg -} // namespace TagLib -} // namespace Strawberry_TagLib + class FilePrivate; + FilePrivate *d; +}; +} // namespace FLAC +} // namespace Ogg +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/ogg/oggfile.cpp b/3rdparty/taglib/ogg/oggfile.cpp index f16b72361..c380ea6d9 100644 --- a/3rdparty/taglib/ogg/oggfile.cpp +++ b/3rdparty/taglib/ogg/oggfile.cpp @@ -34,31 +34,25 @@ using namespace Strawberry_TagLib::TagLib; -namespace -{ - // Returns the first packet index of the right next page to the given one. - unsigned int nextPacketIndex(const Ogg::Page *page) - { - if(page->header()->lastPacketCompleted()) - return page->firstPacketIndex() + page->packetCount(); - else - return page->firstPacketIndex() + page->packetCount() - 1; - } +namespace { +// Returns the first packet index of the right next page to the given one. +unsigned int nextPacketIndex(const Ogg::Page *page) { + if (page->header()->lastPacketCompleted()) + return page->firstPacketIndex() + page->packetCount(); + else + return page->firstPacketIndex() + page->packetCount() - 1; } +} // namespace -class Ogg::File::FilePrivate -{ -public: - FilePrivate() : - streamSerialNumber(0), - firstPageHeader(0), - lastPageHeader(0) - { +class Ogg::File::FilePrivate { + public: + FilePrivate() : streamSerialNumber(0), + firstPageHeader(0), + lastPageHeader(0) { pages.setAutoDelete(true); } - ~FilePrivate() - { + ~FilePrivate() { delete firstPageHeader; delete lastPageHeader; } @@ -74,23 +68,21 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -Ogg::File::~File() -{ +Ogg::File::~File() { delete d; } -ByteVector Ogg::File::packet(unsigned int i) -{ +ByteVector Ogg::File::packet(unsigned int i) { // Check to see if we're called setPacket() for this packet since the last // save: - if(d->dirtyPackets.contains(i)) + if (d->dirtyPackets.contains(i)) return d->dirtyPackets[i]; // If we haven't indexed the page where the packet we're interested in starts, // begin reading pages until we have. - if(!readPages(i)) { + if (!readPages(i)) { debug("Ogg::File::packet() -- Could not find the requested packet."); return ByteVector(); } @@ -98,7 +90,7 @@ ByteVector Ogg::File::packet(unsigned int i) // Look for the first page in which the requested packet starts. List::ConstIterator it = d->pages.begin(); - while((*it)->containsPacket(i) == Page::DoesNotContainPacket) + while ((*it)->containsPacket(i) == Page::DoesNotContainPacket) ++it; // If the packet is completely contained in the first page that it's in. @@ -110,7 +102,7 @@ ByteVector Ogg::File::packet(unsigned int i) ByteVector packet = (*it)->packets()[i - (*it)->firstPacketIndex()]; - while(nextPacketIndex(*it) <= i) { + while (nextPacketIndex(*it) <= i) { ++it; packet.append((*it)->packets().front()); } @@ -118,9 +110,8 @@ ByteVector Ogg::File::packet(unsigned int i) return packet; } -void Ogg::File::setPacket(unsigned int i, const ByteVector &p) -{ - if(!readPages(i)) { +void Ogg::File::setPacket(unsigned int i, const ByteVector &p) { + if (!readPages(i)) { debug("Ogg::File::setPacket() -- Could not set the requested packet."); return; } @@ -128,11 +119,10 @@ void Ogg::File::setPacket(unsigned int i, const ByteVector &p) d->dirtyPackets[i] = p; } -const Ogg::PageHeader *Ogg::File::firstPageHeader() -{ - if(!d->firstPageHeader) { +const Ogg::PageHeader *Ogg::File::firstPageHeader() { + if (!d->firstPageHeader) { const long firstPageHeaderOffset = find("OggS"); - if(firstPageHeaderOffset < 0) + if (firstPageHeaderOffset < 0) return 0; d->firstPageHeader = new PageHeader(this, firstPageHeaderOffset); @@ -141,11 +131,10 @@ const Ogg::PageHeader *Ogg::File::firstPageHeader() return d->firstPageHeader->isValid() ? d->firstPageHeader : 0; } -const Ogg::PageHeader *Ogg::File::lastPageHeader() -{ - if(!d->lastPageHeader) { +const Ogg::PageHeader *Ogg::File::lastPageHeader() { + if (!d->lastPageHeader) { const long lastPageHeaderOffset = rfind("OggS"); - if(lastPageHeaderOffset < 0) + if (lastPageHeaderOffset < 0) return 0; d->lastPageHeader = new PageHeader(this, lastPageHeaderOffset); @@ -154,15 +143,14 @@ const Ogg::PageHeader *Ogg::File::lastPageHeader() return d->lastPageHeader->isValid() ? d->lastPageHeader : 0; } -bool Ogg::File::save() -{ - if(readOnly()) { +bool Ogg::File::save() { + if (readOnly()) { debug("Ogg::File::save() - Cannot save to a read only file."); return false; } Map::ConstIterator it; - for(it = d->dirtyPackets.begin(); it != d->dirtyPackets.end(); ++it) + for (it = d->dirtyPackets.begin(); it != d->dirtyPackets.end(); ++it) writePacket(it->first, it->second); d->dirtyPackets.clear(); @@ -174,32 +162,27 @@ bool Ogg::File::save() // protected members //////////////////////////////////////////////////////////////////////////////// -Ogg::File::File(FileName file) : - Strawberry_TagLib::TagLib::File(file), - d(new FilePrivate()) -{ +Ogg::File::File(FileName file) : Strawberry_TagLib::TagLib::File(file), + d(new FilePrivate()) { } -Ogg::File::File(IOStream *stream) : - Strawberry_TagLib::TagLib::File(stream), - d(new FilePrivate()) -{ +Ogg::File::File(IOStream *stream) : Strawberry_TagLib::TagLib::File(stream), + d(new FilePrivate()) { } //////////////////////////////////////////////////////////////////////////////// // private members //////////////////////////////////////////////////////////////////////////////// -bool Ogg::File::readPages(unsigned int i) -{ - while(true) { +bool Ogg::File::readPages(unsigned int i) { + while (true) { unsigned int packetIndex; long offset; - if(d->pages.isEmpty()) { + if (d->pages.isEmpty()) { packetIndex = 0; offset = find("OggS"); - if(offset < 0) + if (offset < 0) return false; } else { @@ -210,13 +193,13 @@ bool Ogg::File::readPages(unsigned int i) // Enough pages have been fetched. - if(packetIndex > i) + if (packetIndex > i) return true; // Read the next page and add it to the page list. Page *nextPage = new Page(this, offset); - if(!nextPage->header()->isValid()) { + if (!nextPage->header()->isValid()) { delete nextPage; return false; } @@ -224,14 +207,13 @@ bool Ogg::File::readPages(unsigned int i) nextPage->setFirstPacketIndex(packetIndex); d->pages.append(nextPage); - if(nextPage->header()->lastPageOfStream()) + if (nextPage->header()->lastPageOfStream()) return false; } } -void Ogg::File::writePacket(unsigned int i, const ByteVector &packet) -{ - if(!readPages(i)) { +void Ogg::File::writePacket(unsigned int i, const ByteVector &packet) { + if (!readPages(i)) { debug("Ogg::File::writePacket() -- Could not find the requested packet."); return; } @@ -239,12 +221,12 @@ void Ogg::File::writePacket(unsigned int i, const ByteVector &packet) // Look for the pages where the requested packet should belong to. List::ConstIterator it = d->pages.begin(); - while((*it)->containsPacket(i) == Page::DoesNotContainPacket) + while ((*it)->containsPacket(i) == Page::DoesNotContainPacket) ++it; const Page *firstPage = *it; - while(nextPacketIndex(*it) <= i) + while (nextPacketIndex(*it) <= i) ++it; const Page *lastPage = *it; @@ -254,7 +236,7 @@ void Ogg::File::writePacket(unsigned int i, const ByteVector &packet) ByteVectorList packets = firstPage->packets(); packets[i - firstPage->firstPacketIndex()] = packet; - if(firstPage != lastPage && lastPage->packetCount() > 1) { + if (firstPage != lastPage && lastPage->packetCount() > 1) { ByteVectorList lastPagePackets = lastPage->packets(); lastPagePackets.erase(lastPagePackets.begin()); packets.append(lastPagePackets); @@ -264,17 +246,17 @@ void Ogg::File::writePacket(unsigned int i, const ByteVector &packet) // This should account for real possibilities like non-aligned packets and such. List pages = Page::paginate(packets, - Page::SinglePagePerGroup, - firstPage->header()->streamSerialNumber(), - firstPage->pageSequenceNumber(), - firstPage->header()->firstPacketContinued(), - lastPage->header()->lastPacketCompleted()); + Page::SinglePagePerGroup, + firstPage->header()->streamSerialNumber(), + firstPage->pageSequenceNumber(), + firstPage->header()->firstPacketContinued(), + lastPage->header()->lastPacketCompleted()); pages.setAutoDelete(true); // Write the pages. ByteVector data; - for(it = pages.begin(); it != pages.end(); ++it) + for (it = pages.begin(); it != pages.end(); ++it) data.append((*it)->render()); const unsigned long originalOffset = firstPage->fileOffset(); @@ -284,15 +266,14 @@ void Ogg::File::writePacket(unsigned int i, const ByteVector &packet) // Renumber the following pages if the pages have been split or merged. - const int numberOfNewPages - = pages.back()->pageSequenceNumber() - lastPage->pageSequenceNumber(); + const int numberOfNewPages = pages.back()->pageSequenceNumber() - lastPage->pageSequenceNumber(); - if(numberOfNewPages != 0) { + if (numberOfNewPages != 0) { long pageOffset = originalOffset + data.size(); - while(true) { + while (true) { Page page(this, pageOffset); - if(!page.header()->isValid()) + if (!page.header()->isValid()) break; page.setPageSequenceNumber(page.pageSequenceNumber() + numberOfNewPages); @@ -301,7 +282,7 @@ void Ogg::File::writePacket(unsigned int i, const ByteVector &packet) seek(pageOffset + 18); writeBlock(data2.mid(18, 8)); - if(page.header()->lastPageOfStream()) + if (page.header()->lastPageOfStream()) break; pageOffset += page.size(); diff --git a/3rdparty/taglib/ogg/oggfile.h b/3rdparty/taglib/ogg/oggfile.h index 49259ed4f..0c916fb63 100644 --- a/3rdparty/taglib/ogg/oggfile.h +++ b/3rdparty/taglib/ogg/oggfile.h @@ -28,70 +28,69 @@ #include "tbytevectorlist.h" #ifndef TAGLIB_OGGFILE_H -#define TAGLIB_OGGFILE_H +# define TAGLIB_OGGFILE_H namespace Strawberry_TagLib { namespace TagLib { - //! A namespace for the classes used by Ogg-based metadata files +//! A namespace for the classes used by Ogg-based metadata files - namespace Ogg { +namespace Ogg { - class PageHeader; +class PageHeader; - //! An implementation of Strawberry_TagLib::TagLib::File with some helpers for Ogg based formats +//! An implementation of Strawberry_TagLib::TagLib::File with some helpers for Ogg based formats - /*! +/*! * This is an implementation of Ogg file page and packet rendering and is of * use to Ogg based formats. While the API is small this handles the * non-trivial details of breaking up an Ogg stream into packets and makes * these available (via subclassing) to the codec meta data implementations. */ - class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File - { - public: - virtual ~File(); +class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File { + public: + virtual ~File(); - /*! + /*! * Returns the packet contents for the i-th packet (starting from zero) * in the Ogg bitstream. * * \warning This requires reading at least the packet header for every page * up to the requested page. */ - ByteVector packet(unsigned int i); + ByteVector packet(unsigned int i); - /*! + /*! * Sets the packet with index \a i to the value \a p. */ - void setPacket(unsigned int i, const ByteVector &p); + void setPacket(unsigned int i, const ByteVector &p); - /*! + /*! * Returns a pointer to the PageHeader for the first page in the stream or * null if the page could not be found. */ - const PageHeader *firstPageHeader(); + const PageHeader *firstPageHeader(); - /*! + /*! * Returns a pointer to the PageHeader for the last page in the stream or * null if the page could not be found. */ - const PageHeader *lastPageHeader(); + const PageHeader *lastPageHeader(); - virtual bool save(); + virtual bool save(); - protected: - /*! + protected: + /*! * Constructs an Ogg file from \a file. * * \note This constructor is protected since Ogg::File shouldn't be * instantiated directly but rather should be used through the codec * specific subclasses. */ - File(FileName file); + File(FileName file); - /*! + /*! * Constructs an Ogg file from \a stream. * * \note This constructor is protected since Ogg::File shouldn't be @@ -101,29 +100,29 @@ namespace TagLib { * \note TagLib will *not* take ownership of the stream, the caller is * responsible for deleting it after the File object. */ - File(IOStream *stream); + File(IOStream *stream); - private: - File(const File &); - File &operator=(const File &); + private: + File(const File &); + File &operator=(const File &); - /*! + /*! * Reads the pages from the beginning of the file until enough to compose * the requested packet. */ - bool readPages(unsigned int i); + bool readPages(unsigned int i); - /*! + /*! * Writes the requested packet to the file. */ - void writePacket(unsigned int i, const ByteVector &packet); + void writePacket(unsigned int i, const ByteVector &packet); - class FilePrivate; - FilePrivate *d; - }; + class FilePrivate; + FilePrivate *d; +}; - } -} -} +} // namespace Ogg +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/ogg/oggpage.cpp b/3rdparty/taglib/ogg/oggpage.cpp index e2937bceb..9f40a1f6e 100644 --- a/3rdparty/taglib/ogg/oggpage.cpp +++ b/3rdparty/taglib/ogg/oggpage.cpp @@ -34,14 +34,12 @@ using namespace Strawberry_TagLib::TagLib; -class Ogg::Page::PagePrivate -{ -public: - PagePrivate(File *f = 0, long pageOffset = -1) : - file(f), - fileOffset(pageOffset), - header(f, pageOffset), - firstPacketIndex(-1) {} +class Ogg::Page::PagePrivate { + public: + PagePrivate(File *f = 0, long pageOffset = -1) : file(f), + fileOffset(pageOffset), + header(f, pageOffset), + firstPacketIndex(-1) {} File *file; long fileOffset; @@ -54,66 +52,55 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -Ogg::Page::Page(Ogg::File *file, long pageOffset) : - d(new PagePrivate(file, pageOffset)) -{ +Ogg::Page::Page(Ogg::File *file, long pageOffset) : d(new PagePrivate(file, pageOffset)) { } -Ogg::Page::~Page() -{ +Ogg::Page::~Page() { delete d; } -long Ogg::Page::fileOffset() const -{ +long Ogg::Page::fileOffset() const { return d->fileOffset; } -const Ogg::PageHeader *Ogg::Page::header() const -{ +const Ogg::PageHeader *Ogg::Page::header() const { return &d->header; } -int Ogg::Page::pageSequenceNumber() const -{ +int Ogg::Page::pageSequenceNumber() const { return d->header.pageSequenceNumber(); } -void Ogg::Page::setPageSequenceNumber(int sequenceNumber) -{ +void Ogg::Page::setPageSequenceNumber(int sequenceNumber) { d->header.setPageSequenceNumber(sequenceNumber); } -int Ogg::Page::firstPacketIndex() const -{ +int Ogg::Page::firstPacketIndex() const { return d->firstPacketIndex; } -void Ogg::Page::setFirstPacketIndex(int index) -{ +void Ogg::Page::setFirstPacketIndex(int index) { d->firstPacketIndex = index; } -Ogg::Page::ContainsPacketFlags Ogg::Page::containsPacket(int index) const -{ +Ogg::Page::ContainsPacketFlags Ogg::Page::containsPacket(int index) const { const int lastPacketIndex = d->firstPacketIndex + packetCount() - 1; - if(index < d->firstPacketIndex || index > lastPacketIndex) + if (index < d->firstPacketIndex || index > lastPacketIndex) return DoesNotContainPacket; ContainsPacketFlags flags = DoesNotContainPacket; - if(index == d->firstPacketIndex) + if (index == d->firstPacketIndex) flags = ContainsPacketFlags(flags | BeginsWithPacket); - if(index == lastPacketIndex) + if (index == lastPacketIndex) flags = ContainsPacketFlags(flags | EndsWithPacket); // If there's only one page and it's complete: - if(packetCount() == 1 && - !d->header.firstPacketContinued() && - d->header.lastPacketCompleted()) - { + if (packetCount() == 1 && + !d->header.firstPacketContinued() && + d->header.lastPacketCompleted()) { flags = ContainsPacketFlags(flags | CompletePacket); } @@ -121,37 +108,34 @@ Ogg::Page::ContainsPacketFlags Ogg::Page::containsPacket(int index) const // (a) the first page and it's complete or // (b) the last page and it's complete or // (c) a page in the middle. - else if(packetCount() > 1 && - ((flags & BeginsWithPacket && !d->header.firstPacketContinued()) || - (flags & EndsWithPacket && d->header.lastPacketCompleted()) || - (!(flags & BeginsWithPacket) && !(flags & EndsWithPacket)))) - { + else if (packetCount() > 1 && + ((flags & BeginsWithPacket && !d->header.firstPacketContinued()) || + (flags & EndsWithPacket && d->header.lastPacketCompleted()) || + (!(flags & BeginsWithPacket) && !(flags & EndsWithPacket)))) { flags = ContainsPacketFlags(flags | CompletePacket); } return flags; } -unsigned int Ogg::Page::packetCount() const -{ +unsigned int Ogg::Page::packetCount() const { return d->header.packetSizes().size(); } -ByteVectorList Ogg::Page::packets() const -{ - if(!d->packets.isEmpty()) +ByteVectorList Ogg::Page::packets() const { + if (!d->packets.isEmpty()) return d->packets; ByteVectorList l; - if(d->file && d->header.isValid()) { + if (d->file && d->header.isValid()) { d->file->seek(d->fileOffset + d->header.size()); List packetSizes = d->header.packetSizes(); List::ConstIterator it = packetSizes.begin(); - for(; it != packetSizes.end(); ++it) + for (; it != packetSizes.end(); ++it) l.append(d->file->readBlock(*it)); } else @@ -160,19 +144,17 @@ ByteVectorList Ogg::Page::packets() const return l; } -int Ogg::Page::size() const -{ +int Ogg::Page::size() const { return d->header.size() + d->header.dataSize(); } -ByteVector Ogg::Page::render() const -{ +ByteVector Ogg::Page::render() const { ByteVector data; data.append(d->header.render()); - if(d->packets.isEmpty()) { - if(d->file) { + if (d->packets.isEmpty()) { + if (d->file) { d->file->seek(d->fileOffset + d->header.size()); data.append(d->file->readBlock(d->header.dataSize())); } @@ -181,7 +163,7 @@ ByteVector Ogg::Page::render() const } else { ByteVectorList::ConstIterator it = d->packets.begin(); - for(; it != d->packets.end(); ++it) + for (; it != d->packets.end(); ++it) data.append(*it); } @@ -196,13 +178,12 @@ ByteVector Ogg::Page::render() const } List Ogg::Page::paginate(const ByteVectorList &packets, - PaginationStrategy strategy, - unsigned int streamSerialNumber, - int firstPage, - bool firstPacketContinued, - bool lastPacketCompleted, - bool containsLastPacket) -{ + PaginationStrategy strategy, + unsigned int streamSerialNumber, + int firstPage, + bool firstPacketContinued, + bool lastPacketCompleted, + bool containsLastPacket) { // SplitSize must be a multiple of 255 in order to get the lacing values right // create pages of about 8KB each @@ -210,13 +191,13 @@ List Ogg::Page::paginate(const ByteVectorList &packets, // Force repagination if the segment table will exceed the size limit. - if(strategy != Repaginate) { + if (strategy != Repaginate) { size_t tableSize = 0; - for(ByteVectorList::ConstIterator it = packets.begin(); it != packets.end(); ++it) + for (ByteVectorList::ConstIterator it = packets.begin(); it != packets.end(); ++it) tableSize += it->size() / 255 + 1; - if(tableSize > 255) + if (tableSize > 255) strategy = Repaginate; } @@ -224,11 +205,11 @@ List Ogg::Page::paginate(const ByteVectorList &packets, // Handle creation of multiple pages with appropriate pagination. - if(strategy == Repaginate) { + if (strategy == Repaginate) { int pageIndex = firstPage; - for(ByteVectorList::ConstIterator it = packets.begin(); it != packets.end(); ++it) { + for (ByteVectorList::ConstIterator it = packets.begin(); it != packets.end(); ++it) { const bool lastPacketInList = (it == --packets.end()); @@ -237,7 +218,7 @@ List Ogg::Page::paginate(const ByteVectorList &packets, bool continued = (firstPacketContinued && it == packets.begin()); unsigned int pos = 0; - while(pos < it->size()) { + while (pos < it->size()) { const bool lastSplit = (pos + SplitSize >= it->size()); @@ -245,11 +226,11 @@ List Ogg::Page::paginate(const ByteVectorList &packets, packetList.append(it->mid(pos, SplitSize)); l.append(new Page(packetList, - streamSerialNumber, - pageIndex, - continued, - lastSplit && (lastPacketInList ? lastPacketCompleted : true), - lastSplit && (containsLastPacket && lastPacketInList))); + streamSerialNumber, + pageIndex, + continued, + lastSplit && (lastPacketInList ? lastPacketCompleted : true), + lastSplit && (containsLastPacket && lastPacketInList))); pageIndex++; continued = true; @@ -259,18 +240,17 @@ List Ogg::Page::paginate(const ByteVectorList &packets, } else { l.append(new Page(packets, - streamSerialNumber, - firstPage, - firstPacketContinued, - lastPacketCompleted, - containsLastPacket)); + streamSerialNumber, + firstPage, + firstPacketContinued, + lastPacketCompleted, + containsLastPacket)); } return l; } -Ogg::Page* Ogg::Page::getCopyWithNewPageSequenceNumber(int /*sequenceNumber*/) -{ +Ogg::Page *Ogg::Page::getCopyWithNewPageSequenceNumber(int /*sequenceNumber*/) { debug("Ogg::Page::getCopyWithNewPageSequenceNumber() -- This function is obsolete. Returning null."); return nullptr; } @@ -280,13 +260,11 @@ Ogg::Page* Ogg::Page::getCopyWithNewPageSequenceNumber(int /*sequenceNumber*/) //////////////////////////////////////////////////////////////////////////////// Ogg::Page::Page(const ByteVectorList &packets, - unsigned int streamSerialNumber, - int pageNumber, - bool firstPacketContinued, - bool lastPacketCompleted, - bool containsLastPacket) : - d(new PagePrivate()) -{ + unsigned int streamSerialNumber, + int pageNumber, + bool firstPacketContinued, + bool lastPacketCompleted, + bool containsLastPacket) : d(new PagePrivate()) { d->header.setFirstPageOfStream(pageNumber == 0 && !firstPacketContinued); d->header.setLastPageOfStream(containsLastPacket); d->header.setFirstPacketContinued(firstPacketContinued); @@ -299,7 +277,7 @@ Ogg::Page::Page(const ByteVectorList &packets, ByteVector data; List packetSizes; - for(ByteVectorList::ConstIterator it = packets.begin(); it != packets.end(); ++it) { + for (ByteVectorList::ConstIterator it = packets.begin(); it != packets.end(); ++it) { packetSizes.append((*it).size()); data.append(*it); } diff --git a/3rdparty/taglib/ogg/oggpage.h b/3rdparty/taglib/ogg/oggpage.h index 9245ba2c2..68a7bf6ba 100644 --- a/3rdparty/taglib/ogg/oggpage.h +++ b/3rdparty/taglib/ogg/oggpage.h @@ -32,14 +32,14 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace Ogg { +namespace Ogg { - class File; - class PageHeader; +class File; +class PageHeader; - //! An implementation of Ogg pages +//! An implementation of Ogg pages - /*! +/*! * This is an implementation of the pages that make up an Ogg stream. * This handles parsing pages and breaking them down into packets and handles * the details of packets spanning multiple pages and pages that contain @@ -50,43 +50,42 @@ namespace TagLib { * could potentially be useful for non-meta data purposes. */ - class TAGLIB_EXPORT Page - { - public: - /*! +class TAGLIB_EXPORT Page { + public: + /*! * Read an Ogg page from the \a file at the position \a pageOffset. */ - Page(File *file, long pageOffset); + Page(File *file, long pageOffset); - virtual ~Page(); + virtual ~Page(); - /*! + /*! * Returns the page's position within the file (in bytes). */ - long fileOffset() const; + long fileOffset() const; - /*! + /*! * Returns a pointer to the header for this page. This pointer will become * invalid when the page is deleted. */ - const PageHeader *header() const; + const PageHeader *header() const; - /*! + /*! * Returns the index of the page within the Ogg stream. This helps make it * possible to determine if pages have been lost. * * \see setPageSequenceNumber() */ - int pageSequenceNumber() const; + int pageSequenceNumber() const; - /*! + /*! * Sets the page's position in the stream to \a sequenceNumber. * * \see pageSequenceNumber() */ - void setPageSequenceNumber(int sequenceNumber); + void setPageSequenceNumber(int sequenceNumber); - /*! + /*! * Returns a copy of the page with \a sequenceNumber set as sequence number. * * \see header() @@ -94,91 +93,91 @@ namespace TagLib { * * \deprecated Always returns null. */ - TAGLIB_DEPRECATED Page *getCopyWithNewPageSequenceNumber(int sequenceNumber); + TAGLIB_DEPRECATED Page *getCopyWithNewPageSequenceNumber(int sequenceNumber); - /*! + /*! * Returns the index of the first packet wholly or partially contained in * this page. * * \see setFirstPacketIndex() */ - int firstPacketIndex() const; + int firstPacketIndex() const; - /*! + /*! * Sets the index of the first packet in the page. * * \see firstPacketIndex() */ - void setFirstPacketIndex(int index); + void setFirstPacketIndex(int index); - /*! + /*! * When checking to see if a page contains a given packet this set of flags * represents the possible values for that packets status in the page. * * \see containsPacket() */ - enum ContainsPacketFlags { - //! No part of the packet is contained in the page - DoesNotContainPacket = 0x0000, - //! The packet is wholly contained in the page - CompletePacket = 0x0001, - //! The page starts with the given packet - BeginsWithPacket = 0x0002, - //! The page ends with the given packet - EndsWithPacket = 0x0004 - }; + enum ContainsPacketFlags { + //! No part of the packet is contained in the page + DoesNotContainPacket = 0x0000, + //! The packet is wholly contained in the page + CompletePacket = 0x0001, + //! The page starts with the given packet + BeginsWithPacket = 0x0002, + //! The page ends with the given packet + EndsWithPacket = 0x0004 + }; - /*! + /*! * Checks to see if the specified \a packet is contained in the current * page. * * \see ContainsPacketFlags */ - ContainsPacketFlags containsPacket(int index) const; + ContainsPacketFlags containsPacket(int index) const; - /*! + /*! * Returns the number of packets (whole or partial) in this page. */ - unsigned int packetCount() const; + unsigned int packetCount() const; - /*! + /*! * Returns a list of the packets in this page. * * \note Either or both the first and last packets may be only partial. * \see PageHeader::firstPacketContinued() */ - ByteVectorList packets() const; + ByteVectorList packets() const; - /*! + /*! * Returns the size of the page in bytes. */ - int size() const; + int size() const; - ByteVector render() const; + ByteVector render() const; - /*! + /*! * Defines a strategy for pagination, or grouping pages into Ogg packets, * for use with pagination methods. * * \note Yes, I'm aware that this is not a canonical "Strategy Pattern", * the term was simply convenient. */ - enum PaginationStrategy { - /*! + enum PaginationStrategy { + /*! * Attempt to put the specified set of packets into a single Ogg packet. * If the sum of the packet data is greater than will fit into a single * Ogg page -- 65280 bytes -- this will fall back to repagination using * the recommended page sizes. */ - SinglePagePerGroup, - /*! + SinglePagePerGroup, + /*! * Split the packet or group of packets into pages that conform to the * sizes recommended in the Ogg standard. */ - Repaginate - }; + Repaginate + }; - /*! + /*! * Pack \a packets into Ogg pages using the \a strategy for pagination. * The page number indicator inside of the rendered packets will start * with \a firstPage and be incremented for each page rendered. @@ -197,34 +196,34 @@ namespace TagLib { * \see PaginationStrategy * \see List::setAutoDelete() */ - static List paginate(const ByteVectorList &packets, - PaginationStrategy strategy, - unsigned int streamSerialNumber, - int firstPage, - bool firstPacketContinued = false, - bool lastPacketCompleted = true, - bool containsLastPacket = false); + static List paginate(const ByteVectorList &packets, + PaginationStrategy strategy, + unsigned int streamSerialNumber, + int firstPage, + bool firstPacketContinued = false, + bool lastPacketCompleted = true, + bool containsLastPacket = false); - protected: - /*! + protected: + /*! * Creates an Ogg packet based on the data in \a packets. The page number * for each page will be set to \a pageNumber. */ - Page(const ByteVectorList &packets, - unsigned int streamSerialNumber, - int pageNumber, - bool firstPacketContinued = false, - bool lastPacketCompleted = true, - bool containsLastPacket = false); + Page(const ByteVectorList &packets, + unsigned int streamSerialNumber, + int pageNumber, + bool firstPacketContinued = false, + bool lastPacketCompleted = true, + bool containsLastPacket = false); - private: - Page(const Page &); - Page &operator=(const Page &); + private: + Page(const Page &); + Page &operator=(const Page &); - class PagePrivate; - PagePrivate *d; - }; - } -} -} + class PagePrivate; + PagePrivate *d; +}; +} // namespace Ogg +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/ogg/oggpageheader.cpp b/3rdparty/taglib/ogg/oggpageheader.cpp index e49106cef..d972bafc7 100644 --- a/3rdparty/taglib/ogg/oggpageheader.cpp +++ b/3rdparty/taglib/ogg/oggpageheader.cpp @@ -34,20 +34,18 @@ using namespace Strawberry_TagLib::TagLib; -class Ogg::PageHeader::PageHeaderPrivate -{ -public: - PageHeaderPrivate() : - isValid(false), - firstPacketContinued(false), - lastPacketCompleted(false), - firstPageOfStream(false), - lastPageOfStream(false), - absoluteGranularPosition(0), - streamSerialNumber(0), - pageSequenceNumber(-1), - size(0), - dataSize(0) {} +class Ogg::PageHeader::PageHeaderPrivate { + public: + PageHeaderPrivate() : isValid(false), + firstPacketContinued(false), + lastPacketCompleted(false), + firstPageOfStream(false), + lastPageOfStream(false), + absoluteGranularPosition(0), + streamSerialNumber(0), + pageSequenceNumber(-1), + size(0), + dataSize(0) {} bool isValid; List packetSizes; @@ -66,115 +64,92 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -Ogg::PageHeader::PageHeader(Ogg::File *file, long pageOffset) : - d(new PageHeaderPrivate()) -{ - if(file && pageOffset >= 0) +Ogg::PageHeader::PageHeader(Ogg::File *file, long pageOffset) : d(new PageHeaderPrivate()) { + if (file && pageOffset >= 0) read(file, pageOffset); } -Ogg::PageHeader::~PageHeader() -{ +Ogg::PageHeader::~PageHeader() { delete d; } -bool Ogg::PageHeader::isValid() const -{ +bool Ogg::PageHeader::isValid() const { return d->isValid; } -List Ogg::PageHeader::packetSizes() const -{ +List Ogg::PageHeader::packetSizes() const { return d->packetSizes; } -void Ogg::PageHeader::setPacketSizes(const List &sizes) -{ +void Ogg::PageHeader::setPacketSizes(const List &sizes) { d->packetSizes = sizes; } -bool Ogg::PageHeader::firstPacketContinued() const -{ +bool Ogg::PageHeader::firstPacketContinued() const { return d->firstPacketContinued; } -void Ogg::PageHeader::setFirstPacketContinued(bool continued) -{ +void Ogg::PageHeader::setFirstPacketContinued(bool continued) { d->firstPacketContinued = continued; } -bool Ogg::PageHeader::lastPacketCompleted() const -{ +bool Ogg::PageHeader::lastPacketCompleted() const { return d->lastPacketCompleted; } -void Ogg::PageHeader::setLastPacketCompleted(bool completed) -{ +void Ogg::PageHeader::setLastPacketCompleted(bool completed) { d->lastPacketCompleted = completed; } -bool Ogg::PageHeader::firstPageOfStream() const -{ +bool Ogg::PageHeader::firstPageOfStream() const { return d->firstPageOfStream; } -void Ogg::PageHeader::setFirstPageOfStream(bool first) -{ +void Ogg::PageHeader::setFirstPageOfStream(bool first) { d->firstPageOfStream = first; } -bool Ogg::PageHeader::lastPageOfStream() const -{ +bool Ogg::PageHeader::lastPageOfStream() const { return d->lastPageOfStream; } -void Ogg::PageHeader::setLastPageOfStream(bool last) -{ +void Ogg::PageHeader::setLastPageOfStream(bool last) { d->lastPageOfStream = last; } -long long Ogg::PageHeader::absoluteGranularPosition() const -{ +long long Ogg::PageHeader::absoluteGranularPosition() const { return d->absoluteGranularPosition; } -void Ogg::PageHeader::setAbsoluteGranularPosition(long long agp) -{ +void Ogg::PageHeader::setAbsoluteGranularPosition(long long agp) { d->absoluteGranularPosition = agp; } -int Ogg::PageHeader::pageSequenceNumber() const -{ +int Ogg::PageHeader::pageSequenceNumber() const { return d->pageSequenceNumber; } -void Ogg::PageHeader::setPageSequenceNumber(int sequenceNumber) -{ +void Ogg::PageHeader::setPageSequenceNumber(int sequenceNumber) { d->pageSequenceNumber = sequenceNumber; } -unsigned int Ogg::PageHeader::streamSerialNumber() const -{ +unsigned int Ogg::PageHeader::streamSerialNumber() const { return d->streamSerialNumber; } -void Ogg::PageHeader::setStreamSerialNumber(unsigned int n) -{ +void Ogg::PageHeader::setStreamSerialNumber(unsigned int n) { d->streamSerialNumber = n; } -int Ogg::PageHeader::size() const -{ +int Ogg::PageHeader::size() const { return d->size; } -int Ogg::PageHeader::dataSize() const -{ +int Ogg::PageHeader::dataSize() const { return d->dataSize; } -ByteVector Ogg::PageHeader::render() const -{ +ByteVector Ogg::PageHeader::render() const { ByteVector data; // capture pattern @@ -225,8 +200,7 @@ ByteVector Ogg::PageHeader::render() const // private members //////////////////////////////////////////////////////////////////////////////// -void Ogg::PageHeader::read(Ogg::File *file, long pageOffset) -{ +void Ogg::PageHeader::read(Ogg::File *file, long pageOffset) { file->seek(pageOffset); // An Ogg page header is at least 27 bytes, so we'll go ahead and read that @@ -237,7 +211,7 @@ void Ogg::PageHeader::read(Ogg::File *file, long pageOffset) // Sanity check -- make sure that we were in fact able to read as much data as // we asked for and that the page begins with "OggS". - if(data.size() != 27 || !data.startsWith("OggS")) { + if (data.size() != 27 || !data.startsWith("OggS")) { debug("Ogg::PageHeader::read() -- error reading page header"); return; } @@ -245,8 +219,8 @@ void Ogg::PageHeader::read(Ogg::File *file, long pageOffset) const std::bitset<8> flags(data[5]); d->firstPacketContinued = flags.test(0); - d->firstPageOfStream = flags.test(1); - d->lastPageOfStream = flags.test(2); + d->firstPageOfStream = flags.test(1); + d->lastPageOfStream = flags.test(2); d->absoluteGranularPosition = data.toLongLong(6, false); d->streamSerialNumber = data.toUInt(14, false); @@ -262,7 +236,7 @@ void Ogg::PageHeader::read(Ogg::File *file, long pageOffset) // Another sanity check. - if(pageSegmentCount < 1 || int(pageSegments.size()) != pageSegmentCount) + if (pageSegmentCount < 1 || int(pageSegments.size()) != pageSegmentCount) return; // The base size of an Ogg page 27 bytes plus the number of lacing values. @@ -271,17 +245,17 @@ void Ogg::PageHeader::read(Ogg::File *file, long pageOffset) int packetSize = 0; - for(int i = 0; i < pageSegmentCount; i++) { + for (int i = 0; i < pageSegmentCount; i++) { d->dataSize += static_cast(pageSegments[i]); packetSize += static_cast(pageSegments[i]); - if(static_cast(pageSegments[i]) < 255) { + if (static_cast(pageSegments[i]) < 255) { d->packetSizes.append(packetSize); packetSize = 0; } } - if(packetSize > 0) { + if (packetSize > 0) { d->packetSizes.append(packetSize); d->lastPacketCompleted = false; } @@ -291,11 +265,10 @@ void Ogg::PageHeader::read(Ogg::File *file, long pageOffset) d->isValid = true; } -ByteVector Ogg::PageHeader::lacingValues() const -{ +ByteVector Ogg::PageHeader::lacingValues() const { ByteVector data; - for(List::ConstIterator it = d->packetSizes.begin(); it != d->packetSizes.end(); ++it) { + for (List::ConstIterator it = d->packetSizes.begin(); it != d->packetSizes.end(); ++it) { // The size of a packet in an Ogg page is indicated by a series of "lacing // values" where the sum of the values is the packet size in bytes. Each of @@ -304,7 +277,7 @@ ByteVector Ogg::PageHeader::lacingValues() const data.resize(data.size() + (*it / 255), '\xff'); - if(it != --d->packetSizes.end() || d->lastPacketCompleted) + if (it != --d->packetSizes.end() || d->lastPacketCompleted) data.append(static_cast(*it % 255)); } diff --git a/3rdparty/taglib/ogg/oggpageheader.h b/3rdparty/taglib/ogg/oggpageheader.h index 2e2953793..09145ccb0 100644 --- a/3rdparty/taglib/ogg/oggpageheader.h +++ b/3rdparty/taglib/ogg/oggpageheader.h @@ -33,56 +33,55 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace Ogg { +namespace Ogg { - class File; +class File; - //! An implementation of the page headers associated with each Ogg::Page +//! An implementation of the page headers associated with each Ogg::Page - /*! +/*! * This class implements Ogg page headers which contain the information * about Ogg pages needed to break them into packets which can be passed on * to the codecs. */ - class TAGLIB_EXPORT PageHeader - { - public: - /*! +class TAGLIB_EXPORT PageHeader { + public: + /*! * Reads a PageHeader from \a file starting at \a pageOffset. The defaults * create a page with no (and as such, invalid) data that must be set * later. */ - PageHeader(File *file = 0, long pageOffset = -1); + PageHeader(File *file = 0, long pageOffset = -1); - /*! + /*! * Deletes this instance of the PageHeader. */ - virtual ~PageHeader(); + virtual ~PageHeader(); - /*! + /*! * Returns true if the header parsed properly and is valid. */ - bool isValid() const; + bool isValid() const; - /*! + /*! * Ogg pages contain a list of packets (which are used by the contained * codecs). The sizes of these pages is encoded in the page header. This * returns a list of the packet sizes in bytes. * * \see setPacketSizes() */ - List packetSizes() const; + List packetSizes() const; - /*! + /*! * Sets the sizes of the packets in this page to \a sizes. Internally this * updates the lacing values in the header. * * \see packetSizes() */ - void setPacketSizes(const List &sizes); + void setPacketSizes(const List &sizes); - /*! + /*! * Some packets can be continued across multiple pages. If the * first packet in the current page is a continuation this will return * true. If this is page starts with a new packet this will return false. @@ -90,89 +89,89 @@ namespace TagLib { * \see lastPacketCompleted() * \see setFirstPacketContinued() */ - bool firstPacketContinued() const; + bool firstPacketContinued() const; - /*! + /*! * Sets the internal flag indicating if the first packet in this page is * continued to \a continued. * * \see firstPacketContinued() */ - void setFirstPacketContinued(bool continued); + void setFirstPacketContinued(bool continued); - /*! + /*! * Returns true if the last packet of this page is completely contained in * this page. * * \see firstPacketContinued() * \see setLastPacketCompleted() */ - bool lastPacketCompleted() const; + bool lastPacketCompleted() const; - /*! + /*! * Sets the internal flag indicating if the last packet in this page is * complete to \a completed. * * \see lastPacketCompleted() */ - void setLastPacketCompleted(bool completed); + void setLastPacketCompleted(bool completed); - /*! + /*! * This returns true if this is the first page of the Ogg (logical) stream. * * \see setFirstPageOfStream() */ - bool firstPageOfStream() const; + bool firstPageOfStream() const; - /*! + /*! * Marks this page as the first page of the Ogg stream. * * \see firstPageOfStream() */ - void setFirstPageOfStream(bool first); + void setFirstPageOfStream(bool first); - /*! + /*! * This returns true if this is the last page of the Ogg (logical) stream. * * \see setLastPageOfStream() */ - bool lastPageOfStream() const; + bool lastPageOfStream() const; - /*! + /*! * Marks this page as the last page of the Ogg stream. * * \see lastPageOfStream() */ - void setLastPageOfStream(bool last); + void setLastPageOfStream(bool last); - /*! + /*! * A special value of containing the position of the packet to be * interpreted by the codec. In the case of Vorbis this contains the PCM * value and is used to calculate the length of the stream. * * \see setAbsoluteGranularPosition() */ - long long absoluteGranularPosition() const; + long long absoluteGranularPosition() const; - /*! + /*! * A special value of containing the position of the packet to be * interpreted by the codec. It is only supported here so that it may be * copied from one page to another. * * \see absoluteGranularPosition() */ - void setAbsoluteGranularPosition(long long agp); + void setAbsoluteGranularPosition(long long agp); - /*! + /*! * Every Ogg logical stream is given a random serial number which is common * to every page in that logical stream. This returns the serial number of * the stream associated with this packet. * * \see setStreamSerialNumber() */ - unsigned int streamSerialNumber() const; + unsigned int streamSerialNumber() const; - /*! + /*! * Every Ogg logical stream is given a random serial number which is common * to every page in that logical stream. This sets this pages serial * number. This method should be used when adding new pages to a logical @@ -180,55 +179,55 @@ namespace TagLib { * * \see streamSerialNumber() */ - void setStreamSerialNumber(unsigned int n); + void setStreamSerialNumber(unsigned int n); - /*! + /*! * Returns the index of the page within the Ogg stream. This helps make it * possible to determine if pages have been lost. * * \see setPageSequenceNumber() */ - int pageSequenceNumber() const; + int pageSequenceNumber() const; - /*! + /*! * Sets the page's position in the stream to \a sequenceNumber. * * \see pageSequenceNumber() */ - void setPageSequenceNumber(int sequenceNumber); + void setPageSequenceNumber(int sequenceNumber); - /*! + /*! * Returns the complete header size. */ - int size() const; + int size() const; - /*! + /*! * Returns the size of the data portion of the page -- i.e. the size of the * page less the header size. */ - int dataSize() const; + int dataSize() const; - /*! + /*! * Render the page header to binary data. * * \note The checksum -- bytes 22 - 25 -- will be left empty and must be * filled in when rendering the entire page. */ - ByteVector render() const; + ByteVector render() const; - private: - PageHeader(const PageHeader &); - PageHeader &operator=(const PageHeader &); + private: + PageHeader(const PageHeader &); + PageHeader &operator=(const PageHeader &); - void read(Ogg::File *file, long pageOffset); - ByteVector lacingValues() const; + void read(Ogg::File *file, long pageOffset); + ByteVector lacingValues() const; - class PageHeaderPrivate; - PageHeaderPrivate *d; - }; + class PageHeaderPrivate; + PageHeaderPrivate *d; +}; - } -} -} +} // namespace Ogg +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/ogg/opus/opusfile.cpp b/3rdparty/taglib/ogg/opus/opusfile.cpp index a37b782fe..31a4b33b6 100644 --- a/3rdparty/taglib/ogg/opus/opusfile.cpp +++ b/3rdparty/taglib/ogg/opus/opusfile.cpp @@ -37,15 +37,12 @@ using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib::Ogg; -class Opus::File::FilePrivate -{ -public: - FilePrivate() : - comment(0), - properties(0) {} +class Opus::File::FilePrivate { + public: + FilePrivate() : comment(0), + properties(0) {} - ~FilePrivate() - { + ~FilePrivate() { delete comment; delete properties; } @@ -58,8 +55,7 @@ public: // static members //////////////////////////////////////////////////////////////////////////////// -bool Ogg::Opus::File::isSupported(IOStream *stream) -{ +bool Ogg::Opus::File::isSupported(IOStream *stream) { // An Opus file has IDs "OggS" and "OpusHead" somewhere. const ByteVector buffer = Utils::readHeader(stream, bufferSize(), false); @@ -70,50 +66,40 @@ bool Ogg::Opus::File::isSupported(IOStream *stream) // public members //////////////////////////////////////////////////////////////////////////////// -Opus::File::File(FileName file, bool readProperties, Properties::ReadStyle) : - Ogg::File(file), - d(new FilePrivate()) -{ - if(isOpen()) +Opus::File::File(FileName file, bool readProperties, Properties::ReadStyle) : Ogg::File(file), + d(new FilePrivate()) { + if (isOpen()) read(readProperties); } -Opus::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) : - Ogg::File(stream), - d(new FilePrivate()) -{ - if(isOpen()) +Opus::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) : Ogg::File(stream), + d(new FilePrivate()) { + if (isOpen()) read(readProperties); } -Opus::File::~File() -{ +Opus::File::~File() { delete d; } -Ogg::XiphComment *Opus::File::tag() const -{ +Ogg::XiphComment *Opus::File::tag() const { return d->comment; } -PropertyMap Opus::File::properties() const -{ +PropertyMap Opus::File::properties() const { return d->comment->properties(); } -PropertyMap Opus::File::setProperties(const PropertyMap &properties) -{ +PropertyMap Opus::File::setProperties(const PropertyMap &properties) { return d->comment->setProperties(properties); } -Opus::Properties *Opus::File::audioProperties() const -{ +Opus::Properties *Opus::File::audioProperties() const { return d->properties; } -bool Opus::File::save() -{ - if(!d->comment) +bool Opus::File::save() { + if (!d->comment) d->comment = new Ogg::XiphComment(); setPacket(1, ByteVector("OpusTags", 8) + d->comment->render(false)); @@ -125,11 +111,10 @@ bool Opus::File::save() // private members //////////////////////////////////////////////////////////////////////////////// -void Opus::File::read(bool readProperties) -{ +void Opus::File::read(bool readProperties) { ByteVector opusHeaderData = packet(0); - if(!opusHeaderData.startsWith("OpusHead")) { + if (!opusHeaderData.startsWith("OpusHead")) { setValid(false); debug("Opus::File::read() -- invalid Opus identification header"); return; @@ -137,7 +122,7 @@ void Opus::File::read(bool readProperties) ByteVector commentHeaderData = packet(1); - if(!commentHeaderData.startsWith("OpusTags")) { + if (!commentHeaderData.startsWith("OpusTags")) { setValid(false); debug("Opus::File::read() -- invalid Opus tags header"); return; @@ -145,6 +130,6 @@ void Opus::File::read(bool readProperties) d->comment = new Ogg::XiphComment(commentHeaderData.mid(8)); - if(readProperties) + if (readProperties) d->properties = new Properties(this); } diff --git a/3rdparty/taglib/ogg/opus/opusfile.h b/3rdparty/taglib/ogg/opus/opusfile.h index abf2622a1..d9e6fc126 100644 --- a/3rdparty/taglib/ogg/opus/opusfile.h +++ b/3rdparty/taglib/ogg/opus/opusfile.h @@ -38,34 +38,33 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace Ogg { +namespace Ogg { - //! A namespace containing classes for Opus metadata +//! A namespace containing classes for Opus metadata - namespace Opus { +namespace Opus { - //! An implementation of Ogg::File with Opus specific methods +//! An implementation of Ogg::File with Opus specific methods - /*! +/*! * This is the central class in the Ogg Opus metadata processing collection * of classes. It's built upon Ogg::File which handles processing of the Ogg * logical bitstream and breaking it down into pages which are handled by * the codec implementations, in this case Opus specifically. */ - class TAGLIB_EXPORT File : public Ogg::File - { - public: - /*! +class TAGLIB_EXPORT File : public Ogg::File { + public: + /*! * Constructs an Opus file from \a file. If \a readProperties is true the * file's audio properties will also be read. * * \note In the current implementation, \a propertiesStyle is ignored. */ - File(FileName file, bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(FileName file, bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Constructs an Opus file from \a stream. If \a readProperties is true the * file's audio properties will also be read. * @@ -74,67 +73,67 @@ namespace TagLib { * * \note In the current implementation, \a propertiesStyle is ignored. */ - File(IOStream *stream, bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(IOStream *stream, bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Destroys this instance of the File. */ - virtual ~File(); + virtual ~File(); - /*! + /*! * Returns the XiphComment for this file. XiphComment implements the tag * interface, so this serves as the reimplementation of * TagLib::File::tag(). */ - virtual Ogg::XiphComment *tag() const; + virtual Ogg::XiphComment *tag() const; - /*! + /*! * Implements the unified property interface -- export function. * This forwards directly to XiphComment::properties(). */ - PropertyMap properties() const; + PropertyMap properties() const; - /*! + /*! * Implements the unified tag dictionary interface -- import function. * Like properties(), this is a forwarder to the file's XiphComment. */ - PropertyMap setProperties(const PropertyMap &); + PropertyMap setProperties(const PropertyMap &); - /*! + /*! * Returns the Opus::Properties for this file. If no audio properties * were read then this will return a null pointer. */ - virtual Properties *audioProperties() const; + virtual Properties *audioProperties() const; - /*! + /*! * Save the file. * * This returns true if the save was successful. */ - virtual bool save(); + virtual bool save(); - /*! + /*! * Returns whether or not the given \a stream can be opened as an Opus * file. * * \note This method is designed to do a quick check. The result may * not necessarily be correct. */ - static bool isSupported(IOStream *stream); + static bool isSupported(IOStream *stream); - private: - File(const File &); - File &operator=(const File &); + private: + File(const File &); + File &operator=(const File &); - void read(bool readProperties); + void read(bool readProperties); - class FilePrivate; - FilePrivate *d; - }; - } - } -} -} + class FilePrivate; + FilePrivate *d; +}; +} // namespace Opus +} // namespace Ogg +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/ogg/opus/opusproperties.cpp b/3rdparty/taglib/ogg/opus/opusproperties.cpp index bbc40ef9d..7bb69b21f 100644 --- a/3rdparty/taglib/ogg/opus/opusproperties.cpp +++ b/3rdparty/taglib/ogg/opus/opusproperties.cpp @@ -38,15 +38,13 @@ using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib::Ogg; -class Opus::Properties::PropertiesPrivate -{ -public: - PropertiesPrivate() : - length(0), - bitrate(0), - inputSampleRate(0), - channels(0), - opusVersion(0) {} +class Opus::Properties::PropertiesPrivate { + public: + PropertiesPrivate() : length(0), + bitrate(0), + inputSampleRate(0), + channels(0), + opusVersion(0) {} int length; int bitrate; @@ -59,58 +57,47 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -Opus::Properties::Properties(File *file, ReadStyle style) : - AudioProperties(style), - d(new PropertiesPrivate()) -{ +Opus::Properties::Properties(File *file, ReadStyle style) : AudioProperties(style), + d(new PropertiesPrivate()) { read(file); } -Opus::Properties::~Properties() -{ +Opus::Properties::~Properties() { delete d; } -int Opus::Properties::length() const -{ +int Opus::Properties::length() const { return lengthInSeconds(); } -int Ogg::Opus::Properties::lengthInSeconds() const -{ +int Ogg::Opus::Properties::lengthInSeconds() const { return d->length / 1000; } -int Ogg::Opus::Properties::lengthInMilliseconds() const -{ +int Ogg::Opus::Properties::lengthInMilliseconds() const { return d->length; } -int Opus::Properties::bitrate() const -{ +int Opus::Properties::bitrate() const { return d->bitrate; } -int Opus::Properties::sampleRate() const -{ +int Opus::Properties::sampleRate() const { // Opus can decode any stream at a sample rate of 8, 12, 16, 24, or 48 kHz, // so there is no single sample rate. Let's assume it's the highest // possible. return 48000; } -int Opus::Properties::channels() const -{ +int Opus::Properties::channels() const { return d->channels; } -int Opus::Properties::inputSampleRate() const -{ +int Opus::Properties::inputSampleRate() const { return d->inputSampleRate; } -int Opus::Properties::opusVersion() const -{ +int Opus::Properties::opusVersion() const { return d->opusVersion; } @@ -118,8 +105,7 @@ int Opus::Properties::opusVersion() const // private members //////////////////////////////////////////////////////////////////////////////// -void Opus::Properties::read(File *file) -{ +void Opus::Properties::read(File *file) { // Get the identification header from the Ogg implementation. // http://tools.ietf.org/html/draft-terriberry-oggopus-01#section-5.1 @@ -152,16 +138,16 @@ void Opus::Properties::read(File *file) pos += 1; const Ogg::PageHeader *first = file->firstPageHeader(); - const Ogg::PageHeader *last = file->lastPageHeader(); + const Ogg::PageHeader *last = file->lastPageHeader(); - if(first && last) { + if (first && last) { const long long start = first->absoluteGranularPosition(); - const long long end = last->absoluteGranularPosition(); + const long long end = last->absoluteGranularPosition(); - if(start >= 0 && end >= 0) { + if (start >= 0 && end >= 0) { const long long frameCount = (end - start - preSkip); - if(frameCount > 0) { + if (frameCount > 0) { const double length = frameCount * 1000.0 / 48000.0; long fileLengthWithoutOverhead = file->length(); // Ignore the two mandatory header packets, see "3. Packet Organization" @@ -169,7 +155,7 @@ void Opus::Properties::read(File *file) for (unsigned int i = 0; i < 2; ++i) { fileLengthWithoutOverhead -= file->packet(i).size(); } - d->length = static_cast(length + 0.5); + d->length = static_cast(length + 0.5); d->bitrate = static_cast(fileLengthWithoutOverhead * 8.0 / length + 0.5); } } diff --git a/3rdparty/taglib/ogg/opus/opusproperties.h b/3rdparty/taglib/ogg/opus/opusproperties.h index 0b9e3a927..d387c1a2b 100644 --- a/3rdparty/taglib/ogg/opus/opusproperties.h +++ b/3rdparty/taglib/ogg/opus/opusproperties.h @@ -35,34 +35,33 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace Ogg { +namespace Ogg { - namespace Opus { +namespace Opus { - class File; +class File; - //! An implementation of audio property reading for Ogg Opus +//! An implementation of audio property reading for Ogg Opus - /*! +/*! * This reads the data from an Ogg Opus stream found in the AudioProperties * API. */ - class TAGLIB_EXPORT Properties : public AudioProperties - { - public: - /*! +class TAGLIB_EXPORT Properties : public AudioProperties { + public: + /*! * Create an instance of Opus::Properties with the data read from the * Opus::File \a file. */ - Properties(File *file, ReadStyle style = Average); + Properties(File *file, ReadStyle style = Average); - /*! + /*! * Destroys this Opus::Properties instance. */ - virtual ~Properties(); + virtual ~Properties(); - /*! + /*! * Returns the length of the file in seconds. The length is rounded down to * the nearest whole second. * @@ -70,67 +69,67 @@ namespace TagLib { * * \deprecated */ - TAGLIB_DEPRECATED virtual int length() const; + TAGLIB_DEPRECATED virtual int length() const; - /*! + /*! * Returns the length of the file in seconds. The length is rounded down to * the nearest whole second. * * \see lengthInMilliseconds() */ - // BIC: make virtual - int lengthInSeconds() const; + // BIC: make virtual + int lengthInSeconds() const; - /*! + /*! * Returns the length of the file in milliseconds. * * \see lengthInSeconds() */ - // BIC: make virtual - int lengthInMilliseconds() const; + // BIC: make virtual + int lengthInMilliseconds() const; - /*! + /*! * Returns the average bit rate of the file in kb/s. */ - virtual int bitrate() const; + virtual int bitrate() const; - /*! + /*! * Returns the sample rate in Hz. * * \note Always returns 48000, because Opus can decode any stream at a * sample rate of 8, 12, 16, 24, or 48 kHz, */ - virtual int sampleRate() const; + virtual int sampleRate() const; - /*! + /*! * Returns the number of audio channels. */ - virtual int channels() const; + virtual int channels() const; - /*! + /*! * The Opus codec supports decoding at multiple sample rates, there is no * single sample rate of the encoded stream. This returns the sample rate * of the original audio stream. */ - int inputSampleRate() const; + int inputSampleRate() const; - /*! + /*! * Returns the Opus version, in the range 0...255. */ - int opusVersion() const; + int opusVersion() const; - private: - Properties(const Properties &); - Properties &operator=(const Properties &); + private: + Properties(const Properties &); + Properties &operator=(const Properties &); - void read(File *file); + void read(File *file); - class PropertiesPrivate; - PropertiesPrivate *d; - }; - } - } -} -} + class PropertiesPrivate; + PropertiesPrivate *d; +}; +} // namespace Opus +} // namespace Ogg +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/ogg/speex/speexfile.cpp b/3rdparty/taglib/ogg/speex/speexfile.cpp index 65d65f8a1..1c823cde1 100644 --- a/3rdparty/taglib/ogg/speex/speexfile.cpp +++ b/3rdparty/taglib/ogg/speex/speexfile.cpp @@ -37,15 +37,12 @@ using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib::Ogg; -class Speex::File::FilePrivate -{ -public: - FilePrivate() : - comment(0), - properties(0) {} +class Speex::File::FilePrivate { + public: + FilePrivate() : comment(0), + properties(0) {} - ~FilePrivate() - { + ~FilePrivate() { delete comment; delete properties; } @@ -58,8 +55,7 @@ public: // static members //////////////////////////////////////////////////////////////////////////////// -bool Ogg::Speex::File::isSupported(IOStream *stream) -{ +bool Ogg::Speex::File::isSupported(IOStream *stream) { // A Speex file has IDs "OggS" and "Speex " somewhere. const ByteVector buffer = Utils::readHeader(stream, bufferSize(), false); @@ -70,50 +66,40 @@ bool Ogg::Speex::File::isSupported(IOStream *stream) // public members //////////////////////////////////////////////////////////////////////////////// -Speex::File::File(FileName file, bool readProperties, Properties::ReadStyle) : - Ogg::File(file), - d(new FilePrivate()) -{ - if(isOpen()) +Speex::File::File(FileName file, bool readProperties, Properties::ReadStyle) : Ogg::File(file), + d(new FilePrivate()) { + if (isOpen()) read(readProperties); } -Speex::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) : - Ogg::File(stream), - d(new FilePrivate()) -{ - if(isOpen()) +Speex::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) : Ogg::File(stream), + d(new FilePrivate()) { + if (isOpen()) read(readProperties); } -Speex::File::~File() -{ +Speex::File::~File() { delete d; } -Ogg::XiphComment *Speex::File::tag() const -{ +Ogg::XiphComment *Speex::File::tag() const { return d->comment; } -PropertyMap Speex::File::properties() const -{ +PropertyMap Speex::File::properties() const { return d->comment->properties(); } -PropertyMap Speex::File::setProperties(const PropertyMap &properties) -{ +PropertyMap Speex::File::setProperties(const PropertyMap &properties) { return d->comment->setProperties(properties); } -Speex::Properties *Speex::File::audioProperties() const -{ +Speex::Properties *Speex::File::audioProperties() const { return d->properties; } -bool Speex::File::save() -{ - if(!d->comment) +bool Speex::File::save() { + if (!d->comment) d->comment = new Ogg::XiphComment(); setPacket(1, d->comment->render()); @@ -125,11 +111,10 @@ bool Speex::File::save() // private members //////////////////////////////////////////////////////////////////////////////// -void Speex::File::read(bool readProperties) -{ +void Speex::File::read(bool readProperties) { ByteVector speexHeaderData = packet(0); - if(!speexHeaderData.startsWith("Speex ")) { + if (!speexHeaderData.startsWith("Speex ")) { debug("Speex::File::read() -- invalid Speex identification header"); setValid(false); return; @@ -139,6 +124,6 @@ void Speex::File::read(bool readProperties) d->comment = new Ogg::XiphComment(commentHeaderData); - if(readProperties) + if (readProperties) d->properties = new Properties(this); } diff --git a/3rdparty/taglib/ogg/speex/speexfile.h b/3rdparty/taglib/ogg/speex/speexfile.h index 49587ecb8..7ddd528db 100644 --- a/3rdparty/taglib/ogg/speex/speexfile.h +++ b/3rdparty/taglib/ogg/speex/speexfile.h @@ -38,34 +38,33 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace Ogg { +namespace Ogg { - //! A namespace containing classes for Speex metadata +//! A namespace containing classes for Speex metadata - namespace Speex { +namespace Speex { - //! An implementation of Ogg::File with Speex specific methods +//! An implementation of Ogg::File with Speex specific methods - /*! +/*! * This is the central class in the Ogg Speex metadata processing collection * of classes. It's built upon Ogg::File which handles processing of the Ogg * logical bitstream and breaking it down into pages which are handled by * the codec implementations, in this case Speex specifically. */ - class TAGLIB_EXPORT File : public Ogg::File - { - public: - /*! +class TAGLIB_EXPORT File : public Ogg::File { + public: + /*! * Constructs a Speex file from \a file. If \a readProperties is true the * file's audio properties will also be read. * * \note In the current implementation, \a propertiesStyle is ignored. */ - File(FileName file, bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(FileName file, bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Constructs a Speex file from \a stream. If \a readProperties is true the * file's audio properties will also be read. * @@ -74,67 +73,67 @@ namespace TagLib { * * \note In the current implementation, \a propertiesStyle is ignored. */ - File(IOStream *stream, bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(IOStream *stream, bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Destroys this instance of the File. */ - virtual ~File(); + virtual ~File(); - /*! + /*! * Returns the XiphComment for this file. XiphComment implements the tag * interface, so this serves as the reimplementation of * TagLib::File::tag(). */ - virtual Ogg::XiphComment *tag() const; + virtual Ogg::XiphComment *tag() const; - /*! + /*! * Implements the unified property interface -- export function. * This forwards directly to XiphComment::properties(). */ - PropertyMap properties() const; + PropertyMap properties() const; - /*! + /*! * Implements the unified tag dictionary interface -- import function. * Like properties(), this is a forwarder to the file's XiphComment. */ - PropertyMap setProperties(const PropertyMap &); + PropertyMap setProperties(const PropertyMap &); - /*! + /*! * Returns the Speex::Properties for this file. If no audio properties * were read then this will return a null pointer. */ - virtual Properties *audioProperties() const; + virtual Properties *audioProperties() const; - /*! + /*! * Save the file. * * This returns true if the save was successful. */ - virtual bool save(); + virtual bool save(); - /*! + /*! * Returns whether or not the given \a stream can be opened as a Speex * file. * * \note This method is designed to do a quick check. The result may * not necessarily be correct. */ - static bool isSupported(IOStream *stream); + static bool isSupported(IOStream *stream); - private: - File(const File &); - File &operator=(const File &); + private: + File(const File &); + File &operator=(const File &); - void read(bool readProperties); + void read(bool readProperties); - class FilePrivate; - FilePrivate *d; - }; - } - } -} -} + class FilePrivate; + FilePrivate *d; +}; +} // namespace Speex +} // namespace Ogg +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/ogg/speex/speexproperties.cpp b/3rdparty/taglib/ogg/speex/speexproperties.cpp index 12d5e1c4e..864a1cfba 100644 --- a/3rdparty/taglib/ogg/speex/speexproperties.cpp +++ b/3rdparty/taglib/ogg/speex/speexproperties.cpp @@ -38,18 +38,16 @@ using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib::Ogg; -class Speex::Properties::PropertiesPrivate -{ -public: - PropertiesPrivate() : - length(0), - bitrate(0), - bitrateNominal(0), - sampleRate(0), - channels(0), - speexVersion(0), - vbr(false), - mode(0) {} +class Speex::Properties::PropertiesPrivate { + public: + PropertiesPrivate() : length(0), + bitrate(0), + bitrateNominal(0), + sampleRate(0), + channels(0), + speexVersion(0), + vbr(false), + mode(0) {} int length; int bitrate; @@ -65,55 +63,44 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -Speex::Properties::Properties(File *file, ReadStyle style) : - AudioProperties(style), - d(new PropertiesPrivate()) -{ +Speex::Properties::Properties(File *file, ReadStyle style) : AudioProperties(style), + d(new PropertiesPrivate()) { read(file); } -Speex::Properties::~Properties() -{ +Speex::Properties::~Properties() { delete d; } -int Speex::Properties::length() const -{ +int Speex::Properties::length() const { return lengthInSeconds(); } -int Speex::Properties::lengthInSeconds() const -{ +int Speex::Properties::lengthInSeconds() const { return d->length / 1000; } -int Speex::Properties::lengthInMilliseconds() const -{ +int Speex::Properties::lengthInMilliseconds() const { return d->length; } -int Speex::Properties::bitrate() const -{ +int Speex::Properties::bitrate() const { return d->bitrate; } -int Speex::Properties::bitrateNominal() const -{ +int Speex::Properties::bitrateNominal() const { return d->bitrateNominal; } -int Speex::Properties::sampleRate() const -{ +int Speex::Properties::sampleRate() const { return d->sampleRate; } -int Speex::Properties::channels() const -{ +int Speex::Properties::channels() const { return d->channels; } -int Speex::Properties::speexVersion() const -{ +int Speex::Properties::speexVersion() const { return d->speexVersion; } @@ -121,12 +108,11 @@ int Speex::Properties::speexVersion() const // private members //////////////////////////////////////////////////////////////////////////////// -void Speex::Properties::read(File *file) -{ +void Speex::Properties::read(File *file) { // Get the identification header from the Ogg implementation. const ByteVector data = file->packet(0); - if(data.size() < 64) { + if (data.size() < 64) { debug("Speex::Properties::read() -- data is too short."); return; } @@ -171,16 +157,16 @@ void Speex::Properties::read(File *file) // unsigned int framesPerPacket = data.mid(pos, 4).toUInt(false); const Ogg::PageHeader *first = file->firstPageHeader(); - const Ogg::PageHeader *last = file->lastPageHeader(); + const Ogg::PageHeader *last = file->lastPageHeader(); - if(first && last) { + if (first && last) { const long long start = first->absoluteGranularPosition(); - const long long end = last->absoluteGranularPosition(); + const long long end = last->absoluteGranularPosition(); - if(start >= 0 && end >= 0 && d->sampleRate > 0) { + if (start >= 0 && end >= 0 && d->sampleRate > 0) { const long long frameCount = end - start; - if(frameCount > 0) { + if (frameCount > 0) { const double length = frameCount * 1000.0 / d->sampleRate; long fileLengthWithoutOverhead = file->length(); // Ignore the two header packets, see "Ogg file format" in @@ -188,7 +174,7 @@ void Speex::Properties::read(File *file) for (unsigned int i = 0; i < 2; ++i) { fileLengthWithoutOverhead -= file->packet(i).size(); } - d->length = static_cast(length + 0.5); + d->length = static_cast(length + 0.5); d->bitrate = static_cast(fileLengthWithoutOverhead * 8.0 / length + 0.5); } } @@ -202,6 +188,6 @@ void Speex::Properties::read(File *file) // Alternative to the actual average bitrate. - if(d->bitrate == 0 && d->bitrateNominal > 0) + if (d->bitrate == 0 && d->bitrateNominal > 0) d->bitrate = static_cast(d->bitrateNominal / 1000.0 + 0.5); } diff --git a/3rdparty/taglib/ogg/speex/speexproperties.h b/3rdparty/taglib/ogg/speex/speexproperties.h index 0c4bb9532..395f81737 100644 --- a/3rdparty/taglib/ogg/speex/speexproperties.h +++ b/3rdparty/taglib/ogg/speex/speexproperties.h @@ -35,34 +35,33 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace Ogg { +namespace Ogg { - namespace Speex { +namespace Speex { - class File; +class File; - //! An implementation of audio property reading for Ogg Speex +//! An implementation of audio property reading for Ogg Speex - /*! +/*! * This reads the data from an Ogg Speex stream found in the AudioProperties * API. */ - class TAGLIB_EXPORT Properties : public AudioProperties - { - public: - /*! +class TAGLIB_EXPORT Properties : public AudioProperties { + public: + /*! * Create an instance of Speex::Properties with the data read from the * Speex::File \a file. */ - Properties(File *file, ReadStyle style = Average); + Properties(File *file, ReadStyle style = Average); - /*! + /*! * Destroys this Speex::Properties instance. */ - virtual ~Properties(); + virtual ~Properties(); - /*! + /*! * Returns the length of the file in seconds. The length is rounded down to * the nearest whole second. * @@ -70,62 +69,62 @@ namespace TagLib { * * \deprecated */ - TAGLIB_DEPRECATED virtual int length() const; + TAGLIB_DEPRECATED virtual int length() const; - /*! + /*! * Returns the length of the file in seconds. The length is rounded down to * the nearest whole second. * * \see lengthInMilliseconds() */ - // BIC: make virtual - int lengthInSeconds() const; + // BIC: make virtual + int lengthInSeconds() const; - /*! + /*! * Returns the length of the file in milliseconds. * * \see lengthInSeconds() */ - // BIC: make virtual - int lengthInMilliseconds() const; + // BIC: make virtual + int lengthInMilliseconds() const; - /*! + /*! * Returns the average bit rate of the file in kb/s. */ - virtual int bitrate() const; + virtual int bitrate() const; - /*! + /*! * Returns the nominal bit rate as read from the Speex header in kb/s. */ - int bitrateNominal() const; + int bitrateNominal() const; - /*! + /*! * Returns the sample rate in Hz. */ - virtual int sampleRate() const; + virtual int sampleRate() const; - /*! + /*! * Returns the number of audio channels. */ - virtual int channels() const; + virtual int channels() const; - /*! + /*! * Returns the Speex version, currently "0" (as specified by the spec). */ - int speexVersion() const; + int speexVersion() const; - private: - Properties(const Properties &); - Properties &operator=(const Properties &); + private: + Properties(const Properties &); + Properties &operator=(const Properties &); - void read(File *file); + void read(File *file); - class PropertiesPrivate; - PropertiesPrivate *d; - }; - } - } -} -} + class PropertiesPrivate; + PropertiesPrivate *d; +}; +} // namespace Speex +} // namespace Ogg +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/ogg/vorbis/vorbisfile.cpp b/3rdparty/taglib/ogg/vorbis/vorbisfile.cpp index 87f235fad..474e24ac5 100644 --- a/3rdparty/taglib/ogg/vorbis/vorbisfile.cpp +++ b/3rdparty/taglib/ogg/vorbis/vorbisfile.cpp @@ -34,15 +34,12 @@ using namespace Strawberry_TagLib::TagLib; -class Vorbis::File::FilePrivate -{ -public: - FilePrivate() : - comment(0), - properties(0) {} +class Vorbis::File::FilePrivate { + public: + FilePrivate() : comment(0), + properties(0) {} - ~FilePrivate() - { + ~FilePrivate() { delete comment; delete properties; } @@ -53,20 +50,19 @@ public: namespace Strawberry_TagLib { namespace TagLib { - /*! +/*! * Vorbis headers can be found with one type ID byte and the string "vorbis" in * an Ogg stream. 0x03 indicates the comment header. */ - static const char vorbisCommentHeaderID[] = { 0x03, 'v', 'o', 'r', 'b', 'i', 's', 0 }; -} -} +static const char vorbisCommentHeaderID[] = { 0x03, 'v', 'o', 'r', 'b', 'i', 's', 0 }; +} // namespace TagLib +} // namespace Strawberry_TagLib //////////////////////////////////////////////////////////////////////////////// // static members //////////////////////////////////////////////////////////////////////////////// -bool Vorbis::File::isSupported(IOStream *stream) -{ +bool Vorbis::File::isSupported(IOStream *stream) { // An Ogg Vorbis file has IDs "OggS" and "\x01vorbis" somewhere. const ByteVector buffer = Utils::readHeader(stream, bufferSize(), false); @@ -77,52 +73,42 @@ bool Vorbis::File::isSupported(IOStream *stream) // public members //////////////////////////////////////////////////////////////////////////////// -Vorbis::File::File(FileName file, bool readProperties, Properties::ReadStyle) : - Ogg::File(file), - d(new FilePrivate()) -{ - if(isOpen()) +Vorbis::File::File(FileName file, bool readProperties, Properties::ReadStyle) : Ogg::File(file), + d(new FilePrivate()) { + if (isOpen()) read(readProperties); } -Vorbis::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) : - Ogg::File(stream), - d(new FilePrivate()) -{ - if(isOpen()) +Vorbis::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) : Ogg::File(stream), + d(new FilePrivate()) { + if (isOpen()) read(readProperties); } -Vorbis::File::~File() -{ +Vorbis::File::~File() { delete d; } -Ogg::XiphComment *Vorbis::File::tag() const -{ +Ogg::XiphComment *Vorbis::File::tag() const { return d->comment; } -PropertyMap Vorbis::File::properties() const -{ +PropertyMap Vorbis::File::properties() const { return d->comment->properties(); } -PropertyMap Vorbis::File::setProperties(const PropertyMap &properties) -{ +PropertyMap Vorbis::File::setProperties(const PropertyMap &properties) { return d->comment->setProperties(properties); } -Vorbis::Properties *Vorbis::File::audioProperties() const -{ +Vorbis::Properties *Vorbis::File::audioProperties() const { return d->properties; } -bool Vorbis::File::save() -{ +bool Vorbis::File::save() { ByteVector v(vorbisCommentHeaderID); - if(!d->comment) + if (!d->comment) d->comment = new Ogg::XiphComment(); v.append(d->comment->render()); @@ -135,11 +121,10 @@ bool Vorbis::File::save() // private members //////////////////////////////////////////////////////////////////////////////// -void Vorbis::File::read(bool readProperties) -{ +void Vorbis::File::read(bool readProperties) { ByteVector commentHeaderData = packet(1); - if(commentHeaderData.mid(0, 7) != vorbisCommentHeaderID) { + if (commentHeaderData.mid(0, 7) != vorbisCommentHeaderID) { debug("Vorbis::File::read() - Could not find the Vorbis comment header."); setValid(false); return; @@ -147,6 +132,6 @@ void Vorbis::File::read(bool readProperties) d->comment = new Ogg::XiphComment(commentHeaderData.mid(7)); - if(readProperties) + if (readProperties) d->properties = new Properties(this); } diff --git a/3rdparty/taglib/ogg/vorbis/vorbisfile.h b/3rdparty/taglib/ogg/vorbis/vorbisfile.h index f1bfdba94..4068050bf 100644 --- a/3rdparty/taglib/ogg/vorbis/vorbisfile.h +++ b/3rdparty/taglib/ogg/vorbis/vorbisfile.h @@ -43,36 +43,35 @@ namespace TagLib { */ #ifdef DOXYGEN - namespace Ogg { +namespace Ogg { #endif - //! A namespace containing classes for Vorbis metadata +//! A namespace containing classes for Vorbis metadata - namespace Vorbis { +namespace Vorbis { - //! An implementation of Ogg::File with Vorbis specific methods +//! An implementation of Ogg::File with Vorbis specific methods - /*! +/*! * This is the central class in the Ogg Vorbis metadata processing collection * of classes. It's built upon Ogg::File which handles processing of the Ogg * logical bitstream and breaking it down into pages which are handled by * the codec implementations, in this case Vorbis specifically. */ - class TAGLIB_EXPORT File : public Ogg::File - { - public: - /*! +class TAGLIB_EXPORT File : public Ogg::File { + public: + /*! * Constructs a Vorbis file from \a file. If \a readProperties is true the * file's audio properties will also be read. * * \note In the current implementation, \a propertiesStyle is ignored. */ - File(FileName file, bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(FileName file, bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Constructs a Vorbis file from \a stream. If \a readProperties is true the * file's audio properties will also be read. * @@ -81,65 +80,65 @@ namespace TagLib { * * \note In the current implementation, \a propertiesStyle is ignored. */ - File(IOStream *stream, bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(IOStream *stream, bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Destroys this instance of the File. */ - virtual ~File(); + virtual ~File(); - /*! + /*! * Returns the XiphComment for this file. XiphComment implements the tag * interface, so this serves as the reimplementation of * TagLib::File::tag(). */ - virtual Ogg::XiphComment *tag() const; + virtual Ogg::XiphComment *tag() const; - /*! + /*! * Implements the unified property interface -- export function. * This forwards directly to XiphComment::properties(). */ - PropertyMap properties() const; + PropertyMap properties() const; - /*! + /*! * Implements the unified tag dictionary interface -- import function. * Like properties(), this is a forwarder to the file's XiphComment. */ - PropertyMap setProperties(const PropertyMap &); + PropertyMap setProperties(const PropertyMap &); - /*! + /*! * Returns the Vorbis::Properties for this file. If no audio properties * were read then this will return a null pointer. */ - virtual Properties *audioProperties() const; + virtual Properties *audioProperties() const; - /*! + /*! * Save the file. * * This returns true if the save was successful. */ - virtual bool save(); + virtual bool save(); - /*! + /*! * Check if the given \a stream can be opened as an Ogg Vorbis file. * * \note This method is designed to do a quick check. The result may * not necessarily be correct. */ - static bool isSupported(IOStream *stream); + static bool isSupported(IOStream *stream); - private: - File(const File &); - File &operator=(const File &); + private: + File(const File &); + File &operator=(const File &); - void read(bool readProperties); + void read(bool readProperties); - class FilePrivate; - FilePrivate *d; - }; - } + class FilePrivate; + FilePrivate *d; +}; +} // namespace Vorbis /* * To keep compatibility with the current version put Vorbis in the Ogg namespace @@ -148,12 +147,16 @@ namespace TagLib { */ #ifdef DOXYGEN - } +} #else - namespace Ogg { namespace Vorbis { typedef Strawberry_TagLib::TagLib::Vorbis::File File; } } +namespace Ogg { +namespace Vorbis { +typedef Strawberry_TagLib::TagLib::Vorbis::File File; +} +} // namespace Ogg #endif -} -} +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/ogg/vorbis/vorbisproperties.cpp b/3rdparty/taglib/ogg/vorbis/vorbisproperties.cpp index 512e04967..eb0944555 100644 --- a/3rdparty/taglib/ogg/vorbis/vorbisproperties.cpp +++ b/3rdparty/taglib/ogg/vorbis/vorbisproperties.cpp @@ -33,18 +33,16 @@ using namespace Strawberry_TagLib::TagLib; -class Vorbis::Properties::PropertiesPrivate -{ -public: - PropertiesPrivate() : - length(0), - bitrate(0), - sampleRate(0), - channels(0), - vorbisVersion(0), - bitrateMaximum(0), - bitrateNominal(0), - bitrateMinimum(0) {} +class Vorbis::Properties::PropertiesPrivate { + public: + PropertiesPrivate() : length(0), + bitrate(0), + sampleRate(0), + channels(0), + vorbisVersion(0), + bitrateMaximum(0), + bitrateNominal(0), + bitrateMinimum(0) {} int length; int bitrate; @@ -58,77 +56,64 @@ public: namespace Strawberry_TagLib { namespace TagLib { - /*! +/*! * Vorbis headers can be found with one type ID byte and the string "vorbis" in * an Ogg stream. 0x01 indicates the setup header. */ - static const char vorbisSetupHeaderID[] = { 0x01, 'v', 'o', 'r', 'b', 'i', 's', 0 }; -} -} +static const char vorbisSetupHeaderID[] = { 0x01, 'v', 'o', 'r', 'b', 'i', 's', 0 }; +} // namespace TagLib +} // namespace Strawberry_TagLib //////////////////////////////////////////////////////////////////////////////// // public members //////////////////////////////////////////////////////////////////////////////// -Vorbis::Properties::Properties(File *file, ReadStyle style) : - AudioProperties(style), - d(new PropertiesPrivate()) -{ +Vorbis::Properties::Properties(File *file, ReadStyle style) : AudioProperties(style), + d(new PropertiesPrivate()) { read(file); } -Vorbis::Properties::~Properties() -{ +Vorbis::Properties::~Properties() { delete d; } -int Vorbis::Properties::length() const -{ +int Vorbis::Properties::length() const { return lengthInSeconds(); } -int Vorbis::Properties::lengthInSeconds() const -{ +int Vorbis::Properties::lengthInSeconds() const { return d->length / 1000; } -int Vorbis::Properties::lengthInMilliseconds() const -{ +int Vorbis::Properties::lengthInMilliseconds() const { return d->length; } -int Vorbis::Properties::bitrate() const -{ +int Vorbis::Properties::bitrate() const { return d->bitrate; } -int Vorbis::Properties::sampleRate() const -{ +int Vorbis::Properties::sampleRate() const { return d->sampleRate; } -int Vorbis::Properties::channels() const -{ +int Vorbis::Properties::channels() const { return d->channels; } -int Vorbis::Properties::vorbisVersion() const -{ +int Vorbis::Properties::vorbisVersion() const { return d->vorbisVersion; } -int Vorbis::Properties::bitrateMaximum() const -{ +int Vorbis::Properties::bitrateMaximum() const { return d->bitrateMaximum; } -int Vorbis::Properties::bitrateNominal() const -{ +int Vorbis::Properties::bitrateNominal() const { return d->bitrateNominal; } -int Vorbis::Properties::bitrateMinimum() const -{ +int Vorbis::Properties::bitrateMinimum() const { return d->bitrateMinimum; } @@ -136,19 +121,18 @@ int Vorbis::Properties::bitrateMinimum() const // private members //////////////////////////////////////////////////////////////////////////////// -void Vorbis::Properties::read(File *file) -{ +void Vorbis::Properties::read(File *file) { // Get the identification header from the Ogg implementation. const ByteVector data = file->packet(0); - if(data.size() < 28) { + if (data.size() < 28) { debug("Vorbis::Properties::read() -- data is too short."); return; } unsigned int pos = 0; - if(data.mid(pos, 7) != vorbisSetupHeaderID) { + if (data.mid(pos, 7) != vorbisSetupHeaderID) { debug("Vorbis::Properties::read() -- invalid Vorbis identification header"); return; } @@ -177,16 +161,16 @@ void Vorbis::Properties::read(File *file) // for my notes on the topic. const Ogg::PageHeader *first = file->firstPageHeader(); - const Ogg::PageHeader *last = file->lastPageHeader(); + const Ogg::PageHeader *last = file->lastPageHeader(); - if(first && last) { + if (first && last) { const long long start = first->absoluteGranularPosition(); - const long long end = last->absoluteGranularPosition(); + const long long end = last->absoluteGranularPosition(); - if(start >= 0 && end >= 0 && d->sampleRate > 0) { + if (start >= 0 && end >= 0 && d->sampleRate > 0) { const long long frameCount = end - start; - if(frameCount > 0) { + if (frameCount > 0) { const double length = frameCount * 1000.0 / d->sampleRate; long fileLengthWithoutOverhead = file->length(); // Ignore the three initial header packets, see "1.3.1. Decode Setup" in @@ -194,7 +178,7 @@ void Vorbis::Properties::read(File *file) for (unsigned int i = 0; i < 3; ++i) { fileLengthWithoutOverhead -= file->packet(i).size(); } - d->length = static_cast(length + 0.5); + d->length = static_cast(length + 0.5); d->bitrate = static_cast(fileLengthWithoutOverhead * 8.0 / length + 0.5); } } @@ -208,6 +192,6 @@ void Vorbis::Properties::read(File *file) // Alternative to the actual average bitrate. - if(d->bitrate == 0 && d->bitrateNominal > 0) + if (d->bitrate == 0 && d->bitrateNominal > 0) d->bitrate = static_cast(d->bitrateNominal / 1000.0 + 0.5); } diff --git a/3rdparty/taglib/ogg/vorbis/vorbisproperties.h b/3rdparty/taglib/ogg/vorbis/vorbisproperties.h index 94f391f56..17ce9b89d 100644 --- a/3rdparty/taglib/ogg/vorbis/vorbisproperties.h +++ b/3rdparty/taglib/ogg/vorbis/vorbisproperties.h @@ -40,35 +40,34 @@ namespace TagLib { */ #ifdef DOXYGEN - namespace Ogg { +namespace Ogg { #endif - namespace Vorbis { +namespace Vorbis { - class File; +class File; - //! An implementation of audio property reading for Ogg Vorbis +//! An implementation of audio property reading for Ogg Vorbis - /*! +/*! * This reads the data from an Ogg Vorbis stream found in the AudioProperties * API. */ - class TAGLIB_EXPORT Properties : public AudioProperties - { - public: - /*! +class TAGLIB_EXPORT Properties : public AudioProperties { + public: + /*! * Create an instance of Vorbis::Properties with the data read from the * Vorbis::File \a file. */ - Properties(File *file, ReadStyle style = Average); + Properties(File *file, ReadStyle style = Average); - /*! + /*! * Destroys this VorbisProperties instance. */ - virtual ~Properties(); + virtual ~Properties(); - /*! + /*! * Returns the length of the file in seconds. The length is rounded down to * the nearest whole second. * @@ -76,73 +75,73 @@ namespace TagLib { * * \deprecated */ - TAGLIB_DEPRECATED virtual int length() const; + TAGLIB_DEPRECATED virtual int length() const; - /*! + /*! * Returns the length of the file in seconds. The length is rounded down to * the nearest whole second. * * \see lengthInMilliseconds() */ - // BIC: make virtual - int lengthInSeconds() const; + // BIC: make virtual + int lengthInSeconds() const; - /*! + /*! * Returns the length of the file in milliseconds. * * \see lengthInSeconds() */ - // BIC: make virtual - int lengthInMilliseconds() const; + // BIC: make virtual + int lengthInMilliseconds() const; - /*! + /*! * Returns the average bit rate of the file in kb/s. */ - virtual int bitrate() const; + virtual int bitrate() const; - /*! + /*! * Returns the sample rate in Hz. */ - virtual int sampleRate() const; + virtual int sampleRate() const; - /*! + /*! * Returns the number of audio channels. */ - virtual int channels() const; + virtual int channels() const; - /*! + /*! * Returns the Vorbis version, currently "0" (as specified by the spec). */ - int vorbisVersion() const; + int vorbisVersion() const; - /*! + /*! * Returns the maximum bitrate as read from the Vorbis identification * header. */ - int bitrateMaximum() const; + int bitrateMaximum() const; - /*! + /*! * Returns the nominal bitrate as read from the Vorbis identification * header. */ - int bitrateNominal() const; + int bitrateNominal() const; - /*! + /*! * Returns the minimum bitrate as read from the Vorbis identification * header. */ - int bitrateMinimum() const; + int bitrateMinimum() const; - private: - Properties(const Properties &); - Properties &operator=(const Properties &); + private: + Properties(const Properties &); + Properties &operator=(const Properties &); - void read(File *file); + void read(File *file); - class PropertiesPrivate; - PropertiesPrivate *d; - }; - } + class PropertiesPrivate; + PropertiesPrivate *d; +}; +} // namespace Vorbis /* * To keep compatibility with the current version put Vorbis in the Ogg namespace @@ -151,12 +150,16 @@ namespace TagLib { */ #ifdef DOXYGEN - } +} #else - namespace Ogg { namespace Vorbis { typedef Strawberry_TagLib::TagLib::AudioProperties AudioProperties; } } +namespace Ogg { +namespace Vorbis { +typedef Strawberry_TagLib::TagLib::AudioProperties AudioProperties; +} +} // namespace Ogg #endif -} -} +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/ogg/xiphcomment.cpp b/3rdparty/taglib/ogg/xiphcomment.cpp index ea936d939..a3fe52bb2 100644 --- a/3rdparty/taglib/ogg/xiphcomment.cpp +++ b/3rdparty/taglib/ogg/xiphcomment.cpp @@ -32,21 +32,18 @@ using namespace Strawberry_TagLib::TagLib; -namespace -{ - typedef Ogg::FieldListMap::Iterator FieldIterator; - typedef Ogg::FieldListMap::ConstIterator FieldConstIterator; +namespace { +typedef Ogg::FieldListMap::Iterator FieldIterator; +typedef Ogg::FieldListMap::ConstIterator FieldConstIterator; - typedef List PictureList; - typedef PictureList::Iterator PictureIterator; - typedef PictureList::Iterator PictureConstIterator; -} +typedef List PictureList; +typedef PictureList::Iterator PictureIterator; +typedef PictureList::Iterator PictureConstIterator; +} // namespace -class Ogg::XiphComment::XiphCommentPrivate -{ -public: - XiphCommentPrivate() - { +class Ogg::XiphComment::XiphCommentPrivate { + public: + XiphCommentPrivate() { pictureList.setAutoDelete(true); } @@ -60,53 +57,44 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -Ogg::XiphComment::XiphComment() : - Strawberry_TagLib::TagLib::Tag(), - d(new XiphCommentPrivate()) -{ +Ogg::XiphComment::XiphComment() : Strawberry_TagLib::TagLib::Tag(), + d(new XiphCommentPrivate()) { } -Ogg::XiphComment::XiphComment(const ByteVector &data) : - Strawberry_TagLib::TagLib::Tag(), - d(new XiphCommentPrivate()) -{ +Ogg::XiphComment::XiphComment(const ByteVector &data) : Strawberry_TagLib::TagLib::Tag(), + d(new XiphCommentPrivate()) { parse(data); } -Ogg::XiphComment::~XiphComment() -{ +Ogg::XiphComment::~XiphComment() { delete d; } -String Ogg::XiphComment::title() const -{ - if(d->fieldListMap["TITLE"].isEmpty()) +String Ogg::XiphComment::title() const { + if (d->fieldListMap["TITLE"].isEmpty()) return String(); return d->fieldListMap["TITLE"].toString(); } -String Ogg::XiphComment::artist() const -{ - if(d->fieldListMap["ARTIST"].isEmpty()) +String Ogg::XiphComment::artist() const { + if (d->fieldListMap["ARTIST"].isEmpty()) return String(); return d->fieldListMap["ARTIST"].toString(); } -String Ogg::XiphComment::album() const -{ - if(d->fieldListMap["ALBUM"].isEmpty()) +String Ogg::XiphComment::album() const { + if (d->fieldListMap["ALBUM"].isEmpty()) return String(); return d->fieldListMap["ALBUM"].toString(); } -String Ogg::XiphComment::comment() const -{ - if(!d->fieldListMap["DESCRIPTION"].isEmpty()) { +String Ogg::XiphComment::comment() const { + if (!d->fieldListMap["DESCRIPTION"].isEmpty()) { d->commentField = "DESCRIPTION"; return d->fieldListMap["DESCRIPTION"].toString(); } - if(!d->fieldListMap["COMMENT"].isEmpty()) { + if (!d->fieldListMap["COMMENT"].isEmpty()) { d->commentField = "COMMENT"; return d->fieldListMap["COMMENT"].toString(); } @@ -114,50 +102,43 @@ String Ogg::XiphComment::comment() const return String(); } -String Ogg::XiphComment::genre() const -{ - if(d->fieldListMap["GENRE"].isEmpty()) +String Ogg::XiphComment::genre() const { + if (d->fieldListMap["GENRE"].isEmpty()) return String(); return d->fieldListMap["GENRE"].toString(); } -unsigned int Ogg::XiphComment::year() const -{ - if(!d->fieldListMap["DATE"].isEmpty()) +unsigned int Ogg::XiphComment::year() const { + if (!d->fieldListMap["DATE"].isEmpty()) return d->fieldListMap["DATE"].front().toInt(); - if(!d->fieldListMap["YEAR"].isEmpty()) + if (!d->fieldListMap["YEAR"].isEmpty()) return d->fieldListMap["YEAR"].front().toInt(); return 0; } -unsigned int Ogg::XiphComment::track() const -{ - if(!d->fieldListMap["TRACKNUMBER"].isEmpty()) +unsigned int Ogg::XiphComment::track() const { + if (!d->fieldListMap["TRACKNUMBER"].isEmpty()) return d->fieldListMap["TRACKNUMBER"].front().toInt(); - if(!d->fieldListMap["TRACKNUM"].isEmpty()) + if (!d->fieldListMap["TRACKNUM"].isEmpty()) return d->fieldListMap["TRACKNUM"].front().toInt(); return 0; } -void Ogg::XiphComment::setTitle(const String &s) -{ +void Ogg::XiphComment::setTitle(const String &s) { addField("TITLE", s); } -void Ogg::XiphComment::setArtist(const String &s) -{ +void Ogg::XiphComment::setArtist(const String &s) { addField("ARTIST", s); } -void Ogg::XiphComment::setAlbum(const String &s) -{ +void Ogg::XiphComment::setAlbum(const String &s) { addField("ALBUM", s); } -void Ogg::XiphComment::setComment(const String &s) -{ - if(d->commentField.isEmpty()) { - if(!d->fieldListMap["DESCRIPTION"].isEmpty()) +void Ogg::XiphComment::setComment(const String &s) { + if (d->commentField.isEmpty()) { + if (!d->fieldListMap["DESCRIPTION"].isEmpty()) d->commentField = "DESCRIPTION"; else d->commentField = "COMMENT"; @@ -166,44 +147,39 @@ void Ogg::XiphComment::setComment(const String &s) addField(d->commentField, s); } -void Ogg::XiphComment::setGenre(const String &s) -{ +void Ogg::XiphComment::setGenre(const String &s) { addField("GENRE", s); } -void Ogg::XiphComment::setYear(unsigned int i) -{ +void Ogg::XiphComment::setYear(unsigned int i) { removeFields("YEAR"); - if(i == 0) + if (i == 0) removeFields("DATE"); else addField("DATE", String::number(i)); } -void Ogg::XiphComment::setTrack(unsigned int i) -{ +void Ogg::XiphComment::setTrack(unsigned int i) { removeFields("TRACKNUM"); - if(i == 0) + if (i == 0) removeFields("TRACKNUMBER"); else addField("TRACKNUMBER", String::number(i)); } -bool Ogg::XiphComment::isEmpty() const -{ - for(FieldConstIterator it = d->fieldListMap.begin(); it != d->fieldListMap.end(); ++it) { - if(!(*it).second.isEmpty()) +bool Ogg::XiphComment::isEmpty() const { + for (FieldConstIterator it = d->fieldListMap.begin(); it != d->fieldListMap.end(); ++it) { + if (!(*it).second.isEmpty()) return false; } return true; } -unsigned int Ogg::XiphComment::fieldCount() const -{ +unsigned int Ogg::XiphComment::fieldCount() const { unsigned int count = 0; - for(FieldConstIterator it = d->fieldListMap.begin(); it != d->fieldListMap.end(); ++it) + for (FieldConstIterator it = d->fieldListMap.begin(); it != d->fieldListMap.end(); ++it) count += (*it).second.size(); count += d->pictureList.size(); @@ -211,37 +187,33 @@ unsigned int Ogg::XiphComment::fieldCount() const return count; } -const Ogg::FieldListMap &Ogg::XiphComment::fieldListMap() const -{ +const Ogg::FieldListMap &Ogg::XiphComment::fieldListMap() const { return d->fieldListMap; } -PropertyMap Ogg::XiphComment::properties() const -{ +PropertyMap Ogg::XiphComment::properties() const { return d->fieldListMap; } -PropertyMap Ogg::XiphComment::setProperties(const PropertyMap &properties) -{ +PropertyMap Ogg::XiphComment::setProperties(const PropertyMap &properties) { // check which keys are to be deleted StringList toRemove; - for(FieldConstIterator it = d->fieldListMap.begin(); it != d->fieldListMap.end(); ++it) + for (FieldConstIterator it = d->fieldListMap.begin(); it != d->fieldListMap.end(); ++it) if (!properties.contains(it->first)) toRemove.append(it->first); - for(StringList::ConstIterator it = toRemove.begin(); it != toRemove.end(); ++it) - removeFields(*it); + for (StringList::ConstIterator it = toRemove.begin(); it != toRemove.end(); ++it) + removeFields(*it); // now go through keys in \a properties and check that the values match those in the xiph comment PropertyMap invalid; PropertyMap::ConstIterator it = properties.begin(); - for(; it != properties.end(); ++it) - { - if(!checkKey(it->first)) + for (; it != properties.end(); ++it) { + if (!checkKey(it->first)) invalid.insert(it->first, it->second); - else if(!d->fieldListMap.contains(it->first) || !(it->second == d->fieldListMap[it->first])) { + else if (!d->fieldListMap.contains(it->first) || !(it->second == d->fieldListMap[it->first])) { const StringList &sl = it->second; - if(sl.isEmpty()) + if (sl.isEmpty()) // zero size string list -> remove the tag with all values removeFields(it->first); else { @@ -249,7 +221,7 @@ PropertyMap Ogg::XiphComment::setProperties(const PropertyMap &properties) StringList::ConstIterator valueIterator = sl.begin(); addField(it->first, *valueIterator, true); ++valueIterator; - for(; valueIterator != sl.end(); ++valueIterator) + for (; valueIterator != sl.end(); ++valueIterator) addField(it->first, *valueIterator, false); } } @@ -257,108 +229,94 @@ PropertyMap Ogg::XiphComment::setProperties(const PropertyMap &properties) return invalid; } -bool Ogg::XiphComment::checkKey(const String &key) -{ - if(key.size() < 1) +bool Ogg::XiphComment::checkKey(const String &key) { + if (key.size() < 1) return false; // A key may consist of ASCII 0x20 through 0x7D, 0x3D ('=') excluded. - for(String::ConstIterator it = key.begin(); it != key.end(); it++) { - if(*it < 0x20 || *it > 0x7D || *it == 0x3D) - return false; + for (String::ConstIterator it = key.begin(); it != key.end(); it++) { + if (*it < 0x20 || *it > 0x7D || *it == 0x3D) + return false; } return true; } -String Ogg::XiphComment::vendorID() const -{ +String Ogg::XiphComment::vendorID() const { return d->vendorID; } -void Ogg::XiphComment::addField(const String &key, const String &value, bool replace) -{ - if(!checkKey(key)) { +void Ogg::XiphComment::addField(const String &key, const String &value, bool replace) { + if (!checkKey(key)) { debug("Ogg::XiphComment::addField() - Invalid key. Field not added."); return; } const String upperKey = key.upper(); - if(replace) + if (replace) removeFields(upperKey); - if(!key.isEmpty() && !value.isEmpty()) + if (!key.isEmpty() && !value.isEmpty()) d->fieldListMap[upperKey].append(value); } -void Ogg::XiphComment::removeField(const String &key, const String &value) -{ - if(!value.isNull()) +void Ogg::XiphComment::removeField(const String &key, const String &value) { + if (!value.isNull()) removeFields(key, value); else removeFields(key); } -void Ogg::XiphComment::removeFields(const String &key) -{ +void Ogg::XiphComment::removeFields(const String &key) { d->fieldListMap.erase(key.upper()); } -void Ogg::XiphComment::removeFields(const String &key, const String &value) -{ +void Ogg::XiphComment::removeFields(const String &key, const String &value) { StringList &fields = d->fieldListMap[key.upper()]; - for(StringList::Iterator it = fields.begin(); it != fields.end(); ) { - if(*it == value) + for (StringList::Iterator it = fields.begin(); it != fields.end();) { + if (*it == value) it = fields.erase(it); else ++it; } } -void Ogg::XiphComment::removeAllFields() -{ +void Ogg::XiphComment::removeAllFields() { d->fieldListMap.clear(); } -bool Ogg::XiphComment::contains(const String &key) const -{ +bool Ogg::XiphComment::contains(const String &key) const { return !d->fieldListMap[key.upper()].isEmpty(); } -void Ogg::XiphComment::removePicture(FLAC::Picture *picture, bool del) -{ +void Ogg::XiphComment::removePicture(FLAC::Picture *picture, bool del) { PictureIterator it = d->pictureList.find(picture); - if(it != d->pictureList.end()) + if (it != d->pictureList.end()) d->pictureList.erase(it); - if(del) + if (del) delete picture; } -void Ogg::XiphComment::removeAllPictures() -{ +void Ogg::XiphComment::removeAllPictures() { d->pictureList.clear(); } -void Ogg::XiphComment::addPicture(FLAC::Picture * picture) -{ +void Ogg::XiphComment::addPicture(FLAC::Picture *picture) { d->pictureList.append(picture); } -List Ogg::XiphComment::pictureList() -{ +List Ogg::XiphComment::pictureList() { return d->pictureList; } -ByteVector Ogg::XiphComment::render() const -{ +ByteVector Ogg::XiphComment::render() const { return render(true); } -ByteVector Ogg::XiphComment::render(bool addFramingBit) const -{ +ByteVector Ogg::XiphComment::render(bool addFramingBit) const { ByteVector data; // Add the vendor ID length and the vendor ID. It's important to use the @@ -379,7 +337,7 @@ ByteVector Ogg::XiphComment::render(bool addFramingBit) const // std::pair where the first String is the field name and // the StringList is the values associated with that field. - for(FieldListMap::ConstIterator it = d->fieldListMap.begin() ; it != d->fieldListMap.end() ; ++it) { + for (FieldListMap::ConstIterator it = d->fieldListMap.begin(); it != d->fieldListMap.end(); ++it) { // And now iterate over the values of the current list. @@ -387,7 +345,7 @@ ByteVector Ogg::XiphComment::render(bool addFramingBit) const StringList values = (*it).second; StringList::ConstIterator valuesIt = values.begin(); - for(; valuesIt != values.end(); ++valuesIt) { + for (; valuesIt != values.end(); ++valuesIt) { ByteVector fieldData = fieldName.data(String::UTF8); fieldData.append('='); fieldData.append((*valuesIt).data(String::UTF8)); @@ -406,7 +364,7 @@ ByteVector Ogg::XiphComment::render(bool addFramingBit) const // Append the "framing bit". - if(addFramingBit) + if (addFramingBit) data.append(char(1)); return data; @@ -416,8 +374,7 @@ ByteVector Ogg::XiphComment::render(bool addFramingBit) const // protected members //////////////////////////////////////////////////////////////////////////////// -void Ogg::XiphComment::parse(const ByteVector &data) -{ +void Ogg::XiphComment::parse(const ByteVector &data) { // The first thing in the comment data is the vendor ID length, followed by a // UTF8 string with the vendor ID. @@ -434,11 +391,11 @@ void Ogg::XiphComment::parse(const ByteVector &data) const unsigned int commentFields = data.toUInt(pos, false); pos += 4; - if(commentFields > (data.size() - 8) / 4) { + if (commentFields > (data.size() - 8) / 4) { return; } - for(unsigned int i = 0; i < commentFields; i++) { + for (unsigned int i = 0; i < commentFields; i++) { // Each comment field is in the format "KEY=value" in a UTF8 string and has // 4 bytes before the text starts that gives the length. @@ -451,13 +408,13 @@ void Ogg::XiphComment::parse(const ByteVector &data) // Don't go past data end - if(pos > data.size()) + if (pos > data.size()) break; // Check for field separator const int sep = entry.find('='); - if(sep < 1) { + if (sep < 1) { debug("Ogg::XiphComment::parse() - Discarding a field. Separator not found."); continue; } @@ -465,27 +422,27 @@ void Ogg::XiphComment::parse(const ByteVector &data) // Parse the key const String key = String(entry.mid(0, sep), String::UTF8).upper(); - if(!checkKey(key)) { + if (!checkKey(key)) { debug("Ogg::XiphComment::parse() - Discarding a field. Invalid key."); continue; } - if(key == "METADATA_BLOCK_PICTURE" || key == "COVERART") { + if (key == "METADATA_BLOCK_PICTURE" || key == "COVERART") { // Handle Pictures separately const ByteVector picturedata = ByteVector::fromBase64(entry.mid(sep + 1)); - if(picturedata.isEmpty()) { + if (picturedata.isEmpty()) { debug("Ogg::XiphComment::parse() - Discarding a field. Invalid base64 data"); continue; } - if(key[0] == L'M') { + if (key[0] == L'M') { // Decode FLAC Picture - FLAC::Picture * picture = new FLAC::Picture(); - if(picture->parse(picturedata)) { + FLAC::Picture *picture = new FLAC::Picture(); + if (picture->parse(picturedata)) { d->pictureList.append(picture); } else { @@ -497,7 +454,7 @@ void Ogg::XiphComment::parse(const ByteVector &data) // Assume it's some type of image file - FLAC::Picture * picture = new FLAC::Picture(); + FLAC::Picture *picture = new FLAC::Picture(); picture->setData(picturedata); picture->setMimeType("image/"); picture->setType(FLAC::Picture::Other); diff --git a/3rdparty/taglib/ogg/xiphcomment.h b/3rdparty/taglib/ogg/xiphcomment.h index bd713a36b..b38540ab1 100644 --- a/3rdparty/taglib/ogg/xiphcomment.h +++ b/3rdparty/taglib/ogg/xiphcomment.h @@ -38,19 +38,19 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace Ogg { +namespace Ogg { - /*! +/*! * A mapping between a list of field names, or keys, and a list of values * associated with that field. * * \see XiphComment::fieldListMap() */ - typedef Map FieldListMap; +typedef Map FieldListMap; - //! Ogg Vorbis comment implementation +//! Ogg Vorbis comment implementation - /*! +/*! * This class is an implementation of the Ogg Vorbis comment specification, * to be found in section 5 of the Ogg Vorbis specification. Because this * format is also used in other (currently unsupported) Xiph.org formats, it @@ -63,48 +63,47 @@ namespace TagLib { * \see fieldListMap() */ - class TAGLIB_EXPORT XiphComment : public Strawberry_TagLib::TagLib::Tag - { - public: - /*! +class TAGLIB_EXPORT XiphComment : public Strawberry_TagLib::TagLib::Tag { + public: + /*! * Constructs an empty Vorbis comment. */ - XiphComment(); + XiphComment(); - /*! + /*! * Constructs a Vorbis comment from \a data. */ - XiphComment(const ByteVector &data); + XiphComment(const ByteVector &data); - /*! + /*! * Destroys this instance of the XiphComment. */ - virtual ~XiphComment(); + virtual ~XiphComment(); - virtual String title() const; - virtual String artist() const; - virtual String album() const; - virtual String comment() const; - virtual String genre() const; - virtual unsigned int year() const; - virtual unsigned int track() const; + virtual String title() const; + virtual String artist() const; + virtual String album() const; + virtual String comment() const; + virtual String genre() const; + virtual unsigned int year() const; + virtual unsigned int track() const; - virtual void setTitle(const String &s); - virtual void setArtist(const String &s); - virtual void setAlbum(const String &s); - virtual void setComment(const String &s); - virtual void setGenre(const String &s); - virtual void setYear(unsigned int i); - virtual void setTrack(unsigned int i); + virtual void setTitle(const String &s); + virtual void setArtist(const String &s); + virtual void setAlbum(const String &s); + virtual void setComment(const String &s); + virtual void setGenre(const String &s); + virtual void setYear(unsigned int i); + virtual void setTrack(unsigned int i); - virtual bool isEmpty() const; + virtual bool isEmpty() const; - /*! + /*! * Returns the number of fields present in the comment. */ - unsigned int fieldCount() const; + unsigned int fieldCount() const; - /*! + /*! * Returns a reference to the map of field lists. Because Xiph comments * support multiple fields with the same key, a pure Map would not work. * As such this is a Map of string lists, keyed on the comment field name. @@ -140,138 +139,138 @@ namespace TagLib { * \warning You should not modify this data structure directly, instead * use addField() and removeField(). */ - const FieldListMap &fieldListMap() const; + const FieldListMap &fieldListMap() const; - /*! + /*! * Implements the unified property interface -- export function. * The result is a one-to-one match of the Xiph comment, since it is * completely compatible with the property interface (in fact, a Xiph * comment is nothing more than a map from tag names to list of values, * as is the dict interface). */ - PropertyMap properties() const; + PropertyMap properties() const; - /*! + /*! * Implements the unified property interface -- import function. * The tags from the given map will be stored one-to-one in the file, * except for invalid keys (less than one character, non-ASCII, or * containing '=' or '~') in which case the according values will * be contained in the returned PropertyMap. */ - PropertyMap setProperties(const PropertyMap&); + PropertyMap setProperties(const PropertyMap &); - /*! + /*! * Check if the given String is a valid Xiph comment key. */ - static bool checkKey(const String&); + static bool checkKey(const String &); - /*! + /*! * Returns the vendor ID of the Ogg Vorbis encoder. libvorbis 1.0 as the * most common case always returns "Xiph.Org libVorbis I 20020717". */ - String vendorID() const; + String vendorID() const; - /*! + /*! * Add the field specified by \a key with the data \a value. If \a replace * is true, then all of the other fields with the same key will be removed * first. * * If the field value is empty, the field will be removed. */ - void addField(const String &key, const String &value, bool replace = true); + void addField(const String &key, const String &value, bool replace = true); - /*! + /*! * Remove the field specified by \a key with the data \a value. If * \a value is null, all of the fields with the given key will be removed. * * \deprecated Using this method may lead to a linkage error. */ - // BIC: remove and merge with below - TAGLIB_DEPRECATED void removeField(const String &key, const String &value = String()); + // BIC: remove and merge with below + TAGLIB_DEPRECATED void removeField(const String &key, const String &value = String()); - /*! + /*! * Remove all the fields specified by \a key. * * \see removeAllFields() */ - void removeFields(const String &key); + void removeFields(const String &key); - /*! + /*! * Remove all the fields specified by \a key with the data \a value. * * \see removeAllFields() */ - void removeFields(const String &key, const String &value); + void removeFields(const String &key, const String &value); - /*! + /*! * Remove all the fields in the comment. * * \see removeFields() */ - void removeAllFields(); + void removeAllFields(); - /*! + /*! * Returns true if the field is contained within the comment. * * \note This is safer than checking for membership in the FieldListMap. */ - bool contains(const String &key) const; + bool contains(const String &key) const; - /*! + /*! * Renders the comment to a ByteVector suitable for inserting into a file. */ - ByteVector render() const; // BIC: remove and merge with below + ByteVector render() const; // BIC: remove and merge with below - /*! + /*! * Renders the comment to a ByteVector suitable for inserting into a file. * * If \a addFramingBit is true the standard Vorbis comment framing bit will * be appended. However some formats (notably FLAC) do not work with this * in place. */ - ByteVector render(bool addFramingBit) const; + ByteVector render(bool addFramingBit) const; - /*! + /*! * Returns a list of pictures attached to the xiph comment. */ - List pictureList(); + List pictureList(); - /*! + /*! * Removes an picture. If \a del is true the picture's memory * will be freed; if it is false, it must be deleted by the user. */ - void removePicture(FLAC::Picture *picture, bool del = true); + void removePicture(FLAC::Picture *picture, bool del = true); - /*! + /*! * Remove all pictures. */ - void removeAllPictures(); + void removeAllPictures(); - /*! + /*! * Add a new picture to the comment block. The comment block takes ownership of the * picture and will handle freeing its memory. * * \note The file will be saved only after calling save(). */ - void addPicture(FLAC::Picture *picture); + void addPicture(FLAC::Picture *picture); - protected: - /*! + protected: + /*! * Reads the tag from the file specified in the constructor and fills the * FieldListMap. */ - void parse(const ByteVector &data); + void parse(const ByteVector &data); - private: - XiphComment(const XiphComment &); - XiphComment &operator=(const XiphComment &); + private: + XiphComment(const XiphComment &); + XiphComment &operator=(const XiphComment &); - class XiphCommentPrivate; - XiphCommentPrivate *d; - }; - } -} -} + class XiphCommentPrivate; + XiphCommentPrivate *d; +}; +} // namespace Ogg +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/riff/aiff/aifffile.cpp b/3rdparty/taglib/riff/aiff/aifffile.cpp index fdf58a119..14fe3f5aa 100644 --- a/3rdparty/taglib/riff/aiff/aifffile.cpp +++ b/3rdparty/taglib/riff/aiff/aifffile.cpp @@ -34,16 +34,13 @@ using namespace Strawberry_TagLib::TagLib; -class RIFF::AIFF::File::FilePrivate -{ -public: - FilePrivate() : - properties(0), - tag(0), - hasID3v2(false) {} +class RIFF::AIFF::File::FilePrivate { + public: + FilePrivate() : properties(0), + tag(0), + hasID3v2(false) {} - ~FilePrivate() - { + ~FilePrivate() { delete properties; delete tag; } @@ -58,8 +55,7 @@ public: // static members //////////////////////////////////////////////////////////////////////////////// -bool RIFF::AIFF::File::isSupported(IOStream *stream) -{ +bool RIFF::AIFF::File::isSupported(IOStream *stream) { // An AIFF file has to start with "FORM????AIFF" or "FORM????AIFC". const ByteVector id = Utils::readHeader(stream, 12, false); @@ -70,76 +66,64 @@ bool RIFF::AIFF::File::isSupported(IOStream *stream) // public members //////////////////////////////////////////////////////////////////////////////// -RIFF::AIFF::File::File(FileName file, bool readProperties, Properties::ReadStyle) : - RIFF::File(file, BigEndian), - d(new FilePrivate()) -{ - if(isOpen()) +RIFF::AIFF::File::File(FileName file, bool readProperties, Properties::ReadStyle) : RIFF::File(file, BigEndian), + d(new FilePrivate()) { + if (isOpen()) read(readProperties); } -RIFF::AIFF::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) : - RIFF::File(stream, BigEndian), - d(new FilePrivate()) -{ - if(isOpen()) +RIFF::AIFF::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) : RIFF::File(stream, BigEndian), + d(new FilePrivate()) { + if (isOpen()) read(readProperties); } -RIFF::AIFF::File::~File() -{ +RIFF::AIFF::File::~File() { delete d; } -ID3v2::Tag *RIFF::AIFF::File::tag() const -{ +ID3v2::Tag *RIFF::AIFF::File::tag() const { return d->tag; } -PropertyMap RIFF::AIFF::File::properties() const -{ +PropertyMap RIFF::AIFF::File::properties() const { return d->tag->properties(); } -void RIFF::AIFF::File::removeUnsupportedProperties(const StringList &unsupported) -{ +void RIFF::AIFF::File::removeUnsupportedProperties(const StringList &unsupported) { d->tag->removeUnsupportedProperties(unsupported); } -PropertyMap RIFF::AIFF::File::setProperties(const PropertyMap &properties) -{ +PropertyMap RIFF::AIFF::File::setProperties(const PropertyMap &properties) { return d->tag->setProperties(properties); } -RIFF::AIFF::Properties *RIFF::AIFF::File::audioProperties() const -{ +RIFF::AIFF::Properties *RIFF::AIFF::File::audioProperties() const { return d->properties; } -bool RIFF::AIFF::File::save() -{ - return save(ID3v2::v4); +bool RIFF::AIFF::File::save() { + return save(ID3v2::v4); } -bool RIFF::AIFF::File::save(ID3v2::Version version) -{ - if(readOnly()) { +bool RIFF::AIFF::File::save(ID3v2::Version version) { + if (readOnly()) { debug("RIFF::AIFF::File::save() -- File is read only."); return false; } - if(!isValid()) { + if (!isValid()) { debug("RIFF::AIFF::File::save() -- Trying to save invalid file."); return false; } - if(d->hasID3v2) { + if (d->hasID3v2) { removeChunk("ID3 "); removeChunk("id3 "); d->hasID3v2 = false; } - if(tag() && !tag()->isEmpty()) { + if (tag() && !tag()->isEmpty()) { setChunkData("ID3 ", d->tag->render(version)); d->hasID3v2 = true; } @@ -147,8 +131,7 @@ bool RIFF::AIFF::File::save(ID3v2::Version version) return true; } -bool RIFF::AIFF::File::hasID3v2Tag() const -{ +bool RIFF::AIFF::File::hasID3v2Tag() const { return d->hasID3v2; } @@ -156,12 +139,11 @@ bool RIFF::AIFF::File::hasID3v2Tag() const // private members //////////////////////////////////////////////////////////////////////////////// -void RIFF::AIFF::File::read(bool readProperties) -{ - for(unsigned int i = 0; i < chunkCount(); ++i) { +void RIFF::AIFF::File::read(bool readProperties) { + for (unsigned int i = 0; i < chunkCount(); ++i) { const ByteVector name = chunkName(i); - if(name == "ID3 " || name == "id3 ") { - if(!d->tag) { + if (name == "ID3 " || name == "id3 ") { + if (!d->tag) { d->tag = new ID3v2::Tag(this, chunkOffset(i)); d->hasID3v2 = true; } @@ -171,9 +153,9 @@ void RIFF::AIFF::File::read(bool readProperties) } } - if(!d->tag) + if (!d->tag) d->tag = new ID3v2::Tag(); - if(readProperties) + if (readProperties) d->properties = new Properties(this, Properties::Average); } diff --git a/3rdparty/taglib/riff/aiff/aifffile.h b/3rdparty/taglib/riff/aiff/aifffile.h index 5ad8cf4ea..d525c1c59 100644 --- a/3rdparty/taglib/riff/aiff/aifffile.h +++ b/3rdparty/taglib/riff/aiff/aifffile.h @@ -33,41 +33,40 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace RIFF { +namespace RIFF { - //! An implementation of AIFF metadata +//! An implementation of AIFF metadata - /*! +/*! * This is implementation of AIFF metadata. * * This supports an ID3v2 tag as well as reading stream from the ID3 RIFF * chunk as well as properties from the file. */ - namespace AIFF { +namespace AIFF { - //! An implementation of TagLib::File with AIFF specific methods +//! An implementation of TagLib::File with AIFF specific methods - /*! +/*! * This implements and provides an interface for AIFF files to the * TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing * the abstract TagLib::File API as well as providing some additional * information specific to AIFF files. */ - class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::RIFF::File - { - public: - /*! +class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::RIFF::File { + public: + /*! * Constructs an AIFF file from \a file. If \a readProperties is true the * file's audio properties will also be read. * * \note In the current implementation, \a propertiesStyle is ignored. */ - File(FileName file, bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(FileName file, bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Constructs an AIFF file from \a stream. If \a readProperties is true the * file's audio properties will also be read. * @@ -76,15 +75,15 @@ namespace TagLib { * * \note In the current implementation, \a propertiesStyle is ignored. */ - File(IOStream *stream, bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(IOStream *stream, bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Destroys this instance of the File. */ - virtual ~File(); + virtual ~File(); - /*! + /*! * Returns the Tag for this file. * * \note This always returns a valid pointer regardless of whether or not @@ -93,67 +92,67 @@ namespace TagLib { * * \see hasID3v2Tag() */ - virtual ID3v2::Tag *tag() const; + virtual ID3v2::Tag *tag() const; - /*! + /*! * Implements the unified property interface -- export function. * This method forwards to ID3v2::Tag::properties(). */ - PropertyMap properties() const; + PropertyMap properties() const; - void removeUnsupportedProperties(const StringList &properties); + void removeUnsupportedProperties(const StringList &properties); - /*! + /*! * Implements the unified property interface -- import function. * This method forwards to ID3v2::Tag::setProperties(). */ - PropertyMap setProperties(const PropertyMap &); + PropertyMap setProperties(const PropertyMap &); - /*! + /*! * Returns the AIFF::Properties for this file. If no audio properties * were read then this will return a null pointer. */ - virtual Properties *audioProperties() const; + virtual Properties *audioProperties() const; - /*! + /*! * Saves the file. */ - virtual bool save(); + virtual bool save(); - /*! + /*! * Save using a specific ID3v2 version (e.g. v3) */ - bool save(ID3v2::Version version); + bool save(ID3v2::Version version); - /*! + /*! * Returns whether or not the file on disk actually has an ID3v2 tag. * * \see ID3v2Tag() */ - bool hasID3v2Tag() const; + bool hasID3v2Tag() const; - /*! + /*! * Check if the given \a stream can be opened as an AIFF file. * * \note This method is designed to do a quick check. The result may * not necessarily be correct. */ - static bool isSupported(IOStream *stream); + static bool isSupported(IOStream *stream); - private: - File(const File &); - File &operator=(const File &); + private: + File(const File &); + File &operator=(const File &); - void read(bool readProperties); + void read(bool readProperties); - friend class Properties; + friend class Properties; - class FilePrivate; - FilePrivate *d; - }; - } - } -} -} + class FilePrivate; + FilePrivate *d; +}; +} // namespace AIFF +} // namespace RIFF +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/riff/aiff/aiffproperties.cpp b/3rdparty/taglib/riff/aiff/aiffproperties.cpp index 1cbd0f2f8..d762e9204 100644 --- a/3rdparty/taglib/riff/aiff/aiffproperties.cpp +++ b/3rdparty/taglib/riff/aiff/aiffproperties.cpp @@ -30,16 +30,14 @@ using namespace Strawberry_TagLib::TagLib; -class RIFF::AIFF::Properties::PropertiesPrivate -{ -public: - PropertiesPrivate() : - length(0), - bitrate(0), - sampleRate(0), - channels(0), - bitsPerSample(0), - sampleFrames(0) {} +class RIFF::AIFF::Properties::PropertiesPrivate { + public: + PropertiesPrivate() : length(0), + bitrate(0), + sampleRate(0), + channels(0), + bitsPerSample(0), + sampleFrames(0) {} int length; int bitrate; @@ -57,82 +55,65 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -RIFF::AIFF::Properties::Properties(const ByteVector &, ReadStyle style) : - AudioProperties(style), - d(new PropertiesPrivate()) -{ +RIFF::AIFF::Properties::Properties(const ByteVector &, ReadStyle style) : AudioProperties(style), + d(new PropertiesPrivate()) { debug("RIFF::AIFF::Properties::Properties() - This constructor is no longer used."); } -RIFF::AIFF::Properties::Properties(File *file, ReadStyle style) : - AudioProperties(style), - d(new PropertiesPrivate()) -{ +RIFF::AIFF::Properties::Properties(File *file, ReadStyle style) : AudioProperties(style), + d(new PropertiesPrivate()) { read(file); } -RIFF::AIFF::Properties::~Properties() -{ +RIFF::AIFF::Properties::~Properties() { delete d; } -int RIFF::AIFF::Properties::length() const -{ +int RIFF::AIFF::Properties::length() const { return lengthInSeconds(); } -int RIFF::AIFF::Properties::lengthInSeconds() const -{ +int RIFF::AIFF::Properties::lengthInSeconds() const { return d->length / 1000; } -int RIFF::AIFF::Properties::lengthInMilliseconds() const -{ +int RIFF::AIFF::Properties::lengthInMilliseconds() const { return d->length; } -int RIFF::AIFF::Properties::bitrate() const -{ +int RIFF::AIFF::Properties::bitrate() const { return d->bitrate; } -int RIFF::AIFF::Properties::sampleRate() const -{ +int RIFF::AIFF::Properties::sampleRate() const { return d->sampleRate; } -int RIFF::AIFF::Properties::channels() const -{ +int RIFF::AIFF::Properties::channels() const { return d->channels; } -int RIFF::AIFF::Properties::bitsPerSample() const -{ +int RIFF::AIFF::Properties::bitsPerSample() const { return d->bitsPerSample; } -int RIFF::AIFF::Properties::sampleWidth() const -{ +int RIFF::AIFF::Properties::sampleWidth() const { return bitsPerSample(); } -unsigned int RIFF::AIFF::Properties::sampleFrames() const -{ +unsigned int RIFF::AIFF::Properties::sampleFrames() const { return d->sampleFrames; } -bool RIFF::AIFF::Properties::isAiffC() const -{ +bool RIFF::AIFF::Properties::isAiffC() const { return (!d->compressionType.isEmpty()); } -ByteVector RIFF::AIFF::Properties::compressionType() const -{ +ByteVector RIFF::AIFF::Properties::compressionType() const { return d->compressionType; } -String RIFF::AIFF::Properties::compressionName() const -{ +String RIFF::AIFF::Properties::compressionName() const { return d->compressionName; } @@ -140,53 +121,51 @@ String RIFF::AIFF::Properties::compressionName() const // private members //////////////////////////////////////////////////////////////////////////////// -void RIFF::AIFF::Properties::read(File *file) -{ +void RIFF::AIFF::Properties::read(File *file) { ByteVector data; unsigned int streamLength = 0; - for(unsigned int i = 0; i < file->chunkCount(); i++) { + for (unsigned int i = 0; i < file->chunkCount(); i++) { const ByteVector name = file->chunkName(i); - if(name == "COMM") { - if(data.isEmpty()) + if (name == "COMM") { + if (data.isEmpty()) data = file->chunkData(i); else debug("RIFF::AIFF::Properties::read() - Duplicate 'COMM' chunk found."); } - else if(name == "SSND") { - if(streamLength == 0) + else if (name == "SSND") { + if (streamLength == 0) streamLength = file->chunkDataSize(i) + file->chunkPadding(i); else debug("RIFF::AIFF::Properties::read() - Duplicate 'SSND' chunk found."); } } - if(data.size() < 18) { + if (data.size() < 18) { debug("RIFF::AIFF::Properties::read() - 'COMM' chunk not found or too short."); return; } - if(streamLength == 0) { + if (streamLength == 0) { debug("RIFF::AIFF::Properties::read() - 'SSND' chunk not found."); return; } - d->channels = data.toShort(0U); - d->sampleFrames = data.toUInt(2U); + d->channels = data.toShort(0U); + d->sampleFrames = data.toUInt(2U); d->bitsPerSample = data.toShort(6U); const long double sampleRate = data.toFloat80BE(8); - if(sampleRate >= 1.0) + if (sampleRate >= 1.0) d->sampleRate = static_cast(sampleRate + 0.5); - if(d->sampleFrames > 0 && d->sampleRate > 0) { + if (d->sampleFrames > 0 && d->sampleRate > 0) { const double length = d->sampleFrames * 1000.0 / sampleRate; - d->length = static_cast(length + 0.5); + d->length = static_cast(length + 0.5); d->bitrate = static_cast(streamLength * 8.0 / length + 0.5); } - if(data.size() >= 23) { + if (data.size() >= 23) { d->compressionType = data.mid(18, 4); - d->compressionName - = String(data.mid(23, static_cast(data[22])), String::Latin1); + d->compressionName = String(data.mid(23, static_cast(data[22])), String::Latin1); } } diff --git a/3rdparty/taglib/riff/aiff/aiffproperties.h b/3rdparty/taglib/riff/aiff/aiffproperties.h index 00d560a18..d331682ad 100644 --- a/3rdparty/taglib/riff/aiff/aiffproperties.h +++ b/3rdparty/taglib/riff/aiff/aiffproperties.h @@ -31,42 +31,41 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace RIFF { +namespace RIFF { - namespace AIFF { +namespace AIFF { - class File; +class File; - //! An implementation of audio property reading for AIFF +//! An implementation of audio property reading for AIFF - /*! +/*! * This reads the data from an AIFF stream found in the AudioProperties * API. */ - class TAGLIB_EXPORT Properties : public AudioProperties - { - public: - /*! +class TAGLIB_EXPORT Properties : public AudioProperties { + public: + /*! * Create an instance of AIFF::Properties with the data read from the * ByteVector \a data. * * \deprecated */ - TAGLIB_DEPRECATED Properties(const ByteVector &data, ReadStyle style); + TAGLIB_DEPRECATED Properties(const ByteVector &data, ReadStyle style); - /*! + /*! * Create an instance of AIFF::Properties with the data read from the * AIFF::File \a file. */ - Properties(File *file, ReadStyle style); + Properties(File *file, ReadStyle style); - /*! + /*! * Destroys this AIFF::Properties instance. */ - virtual ~Properties(); + virtual ~Properties(); - /*! + /*! * Returns the length of the file in seconds. The length is rounded down to * the nearest whole second. * @@ -74,65 +73,65 @@ namespace TagLib { * * \deprecated */ - TAGLIB_DEPRECATED virtual int length() const; + TAGLIB_DEPRECATED virtual int length() const; - /*! + /*! * Returns the length of the file in seconds. The length is rounded down to * the nearest whole second. * * \see lengthInMilliseconds() */ - // BIC: make virtual - int lengthInSeconds() const; + // BIC: make virtual + int lengthInSeconds() const; - /*! + /*! * Returns the length of the file in milliseconds. * * \see lengthInSeconds() */ - // BIC: make virtual - int lengthInMilliseconds() const; + // BIC: make virtual + int lengthInMilliseconds() const; - /*! + /*! * Returns the average bit rate of the file in kb/s. */ - virtual int bitrate() const; + virtual int bitrate() const; - /*! + /*! * Returns the sample rate in Hz. */ - virtual int sampleRate() const; + virtual int sampleRate() const; - /*! + /*! * Returns the number of audio channels. */ - virtual int channels() const; + virtual int channels() const; - /*! + /*! * Returns the number of bits per audio sample. */ - int bitsPerSample() const; + int bitsPerSample() const; - /*! + /*! * Returns the number of bits per audio sample. * * \note This method is just an alias of bitsPerSample(). * * \deprecated */ - TAGLIB_DEPRECATED int sampleWidth() const; + TAGLIB_DEPRECATED int sampleWidth() const; - /*! + /*! * Returns the number of sample frames */ - unsigned int sampleFrames() const; + unsigned int sampleFrames() const; - /*! + /*! * Returns true if the file is in AIFF-C format, false if AIFF format. */ - bool isAiffC() const; + bool isAiffC() const; - /*! + /*! * Returns the compression type of the AIFF-C file. For example, "NONE" for * not compressed, "ACE2" for ACE 2-to-1. * @@ -140,29 +139,29 @@ namespace TagLib { * * \see isAiffC() */ - ByteVector compressionType() const; + ByteVector compressionType() const; - /*! + /*! * Returns the concrete compression name of the AIFF-C file. * * If the file is in AIFF format, always returns an empty string. * * \see isAiffC() */ - String compressionName() const; + String compressionName() const; - private: - Properties(const Properties &); - Properties &operator=(const Properties &); + private: + Properties(const Properties &); + Properties &operator=(const Properties &); - void read(File *file); + void read(File *file); - class PropertiesPrivate; - PropertiesPrivate *d; - }; - } - } -} -} + class PropertiesPrivate; + PropertiesPrivate *d; +}; +} // namespace AIFF +} // namespace RIFF +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/riff/rifffile.cpp b/3rdparty/taglib/riff/rifffile.cpp index 0f1963bf9..7ffe8b808 100644 --- a/3rdparty/taglib/riff/rifffile.cpp +++ b/3rdparty/taglib/riff/rifffile.cpp @@ -35,21 +35,18 @@ using namespace Strawberry_TagLib::TagLib; -struct Chunk -{ - ByteVector name; +struct Chunk { + ByteVector name; unsigned int offset; unsigned int size; unsigned int padding; }; -class RIFF::File::FilePrivate -{ -public: - explicit FilePrivate(Endianness _endianness) : - endianness(_endianness), - size(0), - sizeOffset(0) {} +class RIFF::File::FilePrivate { + public: + explicit FilePrivate(Endianness _endianness) : endianness(_endianness), + size(0), + sizeOffset(0) {} const Endianness endianness; @@ -63,8 +60,7 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -RIFF::File::~File() -{ +RIFF::File::~File() { delete d; } @@ -72,35 +68,28 @@ RIFF::File::~File() // protected members //////////////////////////////////////////////////////////////////////////////// -RIFF::File::File(FileName file, Endianness endianness) : - Strawberry_TagLib::TagLib::File(file), - d(new FilePrivate(endianness)) -{ - if(isOpen()) +RIFF::File::File(FileName file, Endianness endianness) : Strawberry_TagLib::TagLib::File(file), + d(new FilePrivate(endianness)) { + if (isOpen()) read(); } -RIFF::File::File(IOStream *stream, Endianness endianness) : - Strawberry_TagLib::TagLib::File(stream), - d(new FilePrivate(endianness)) -{ - if(isOpen()) +RIFF::File::File(IOStream *stream, Endianness endianness) : Strawberry_TagLib::TagLib::File(stream), + d(new FilePrivate(endianness)) { + if (isOpen()) read(); } -unsigned int RIFF::File::riffSize() const -{ +unsigned int RIFF::File::riffSize() const { return d->size; } -unsigned int RIFF::File::chunkCount() const -{ +unsigned int RIFF::File::chunkCount() const { return static_cast(d->chunks.size()); } -unsigned int RIFF::File::chunkDataSize(unsigned int i) const -{ - if(i >= d->chunks.size()) { +unsigned int RIFF::File::chunkDataSize(unsigned int i) const { + if (i >= d->chunks.size()) { debug("RIFF::File::chunkDataSize() - Index out of range. Returning 0."); return 0; } @@ -108,9 +97,8 @@ unsigned int RIFF::File::chunkDataSize(unsigned int i) const return d->chunks[i].size; } -unsigned int RIFF::File::chunkOffset(unsigned int i) const -{ - if(i >= d->chunks.size()) { +unsigned int RIFF::File::chunkOffset(unsigned int i) const { + if (i >= d->chunks.size()) { debug("RIFF::File::chunkOffset() - Index out of range. Returning 0."); return 0; } @@ -118,9 +106,8 @@ unsigned int RIFF::File::chunkOffset(unsigned int i) const return d->chunks[i].offset; } -unsigned int RIFF::File::chunkPadding(unsigned int i) const -{ - if(i >= d->chunks.size()) { +unsigned int RIFF::File::chunkPadding(unsigned int i) const { + if (i >= d->chunks.size()) { debug("RIFF::File::chunkPadding() - Index out of range. Returning 0."); return 0; } @@ -128,9 +115,8 @@ unsigned int RIFF::File::chunkPadding(unsigned int i) const return d->chunks[i].padding; } -ByteVector RIFF::File::chunkName(unsigned int i) const -{ - if(i >= d->chunks.size()) { +ByteVector RIFF::File::chunkName(unsigned int i) const { + if (i >= d->chunks.size()) { debug("RIFF::File::chunkName() - Index out of range. Returning an empty vector."); return ByteVector(); } @@ -138,9 +124,8 @@ ByteVector RIFF::File::chunkName(unsigned int i) const return d->chunks[i].name; } -ByteVector RIFF::File::chunkData(unsigned int i) -{ - if(i >= d->chunks.size()) { +ByteVector RIFF::File::chunkData(unsigned int i) { + if (i >= d->chunks.size()) { debug("RIFF::File::chunkData() - Index out of range. Returning an empty vector."); return ByteVector(); } @@ -149,9 +134,8 @@ ByteVector RIFF::File::chunkData(unsigned int i) return readBlock(d->chunks[i].size); } -void RIFF::File::setChunkData(unsigned int i, const ByteVector &data) -{ - if(i >= d->chunks.size()) { +void RIFF::File::setChunkData(unsigned int i, const ByteVector &data) { + if (i >= d->chunks.size()) { debug("RIFF::File::setChunkData() - Index out of range."); return; } @@ -165,14 +149,14 @@ void RIFF::File::setChunkData(unsigned int i, const ByteVector &data) writeChunk(it->name, data, it->offset - 8, it->size + it->padding + 8); - it->size = data.size(); + it->size = data.size(); it->padding = data.size() % 2; const long long diff = static_cast(it->size) + it->padding - originalSize; // Now update the internal offsets - for(++it; it != d->chunks.end(); ++it) + for (++it; it != d->chunks.end(); ++it) it->offset += static_cast(diff); // Update the global size. @@ -180,26 +164,24 @@ void RIFF::File::setChunkData(unsigned int i, const ByteVector &data) updateGlobalSize(); } -void RIFF::File::setChunkData(const ByteVector &name, const ByteVector &data) -{ +void RIFF::File::setChunkData(const ByteVector &name, const ByteVector &data) { setChunkData(name, data, false); } -void RIFF::File::setChunkData(const ByteVector &name, const ByteVector &data, bool alwaysCreate) -{ - if(d->chunks.empty()) { +void RIFF::File::setChunkData(const ByteVector &name, const ByteVector &data, bool alwaysCreate) { + if (d->chunks.empty()) { debug("RIFF::File::setChunkData - No valid chunks found."); return; } - if(alwaysCreate && name != "LIST") { + if (alwaysCreate && name != "LIST") { debug("RIFF::File::setChunkData - alwaysCreate should be used for only \"LIST\" chunks."); return; } - if(!alwaysCreate) { - for(unsigned int i = 0; i < d->chunks.size(); i++) { - if(d->chunks[i].name == name) { + if (!alwaysCreate) { + for (unsigned int i = 0; i < d->chunks.size(); i++) { + if (d->chunks[i].name == name) { setChunkData(i, data); return; } @@ -213,9 +195,9 @@ void RIFF::File::setChunkData(const ByteVector &name, const ByteVector &data, bo Chunk &last = d->chunks.back(); long offset = last.offset + last.size + last.padding; - if(offset & 1) { - if(last.padding == 1) { - last.padding = 0; // This should not happen unless the file is corrupted. + if (offset & 1) { + if (last.padding == 1) { + last.padding = 0; // This should not happen unless the file is corrupted. offset--; removeBlock(offset, 1); } @@ -233,9 +215,9 @@ void RIFF::File::setChunkData(const ByteVector &name, const ByteVector &data, bo // And update our internal structure Chunk chunk; - chunk.name = name; - chunk.size = data.size(); - chunk.offset = offset + 8; + chunk.name = name; + chunk.size = data.size(); + chunk.offset = offset + 8; chunk.padding = data.size() % 2; d->chunks.push_back(chunk); @@ -245,9 +227,8 @@ void RIFF::File::setChunkData(const ByteVector &name, const ByteVector &data, bo updateGlobalSize(); } -void RIFF::File::removeChunk(unsigned int i) -{ - if(i >= d->chunks.size()) { +void RIFF::File::removeChunk(unsigned int i) { + if (i >= d->chunks.size()) { debug("RIFF::File::removeChunk() - Index out of range."); return; } @@ -259,7 +240,7 @@ void RIFF::File::removeChunk(unsigned int i) removeBlock(it->offset - 8, removeSize); it = d->chunks.erase(it); - for(; it != d->chunks.end(); ++it) + for (; it != d->chunks.end(); ++it) it->offset -= removeSize; // Update the global size. @@ -267,10 +248,9 @@ void RIFF::File::removeChunk(unsigned int i) updateGlobalSize(); } -void RIFF::File::removeChunk(const ByteVector &name) -{ - for(int i = static_cast(d->chunks.size()) - 1; i >= 0; --i) { - if(d->chunks[i].name == name) +void RIFF::File::removeChunk(const ByteVector &name) { + for (int i = static_cast(d->chunks.size()) - 1; i >= 0; --i) { + if (d->chunks[i].name == name) removeChunk(i); } } @@ -279,8 +259,7 @@ void RIFF::File::removeChunk(const ByteVector &name) // private members //////////////////////////////////////////////////////////////////////////////// -void RIFF::File::read() -{ +void RIFF::File::read() { const bool bigEndian = (d->endianness == BigEndian); long offset = tell(); @@ -294,48 +273,48 @@ void RIFF::File::read() offset += 8; // + 8: chunk header at least, fix for additional junk bytes - while(offset + 8 <= length()) { + while (offset + 8 <= length()) { seek(offset); - const ByteVector chunkName = readBlock(4); + const ByteVector chunkName = readBlock(4); const unsigned int chunkSize = readBlock(4).toUInt(bigEndian); - if(!isValidChunkName(chunkName)) { + if (!isValidChunkName(chunkName)) { debug("RIFF::File::read() -- Chunk '" + chunkName + "' has invalid ID"); setValid(false); break; } - if(static_cast(offset) + 8 + chunkSize > length()) { + if (static_cast(offset) + 8 + chunkSize > length()) { debug("RIFF::File::read() -- Chunk '" + chunkName + "' has invalid size (larger than the file size)"); setValid(false); break; } Chunk chunk; - chunk.name = chunkName; - chunk.size = chunkSize; - chunk.offset = offset + 8; + chunk.name = chunkName; + chunk.size = chunkSize; + chunk.offset = offset + 8; chunk.padding = 0; offset = chunk.offset + chunk.size; // Check padding - if(offset & 1) { + if (offset & 1) { seek(offset); const ByteVector iByte = readBlock(1); - if(iByte.size() == 1) { + if (iByte.size() == 1) { bool skipPadding = iByte[0] == '\0'; - if(!skipPadding) { + if (!skipPadding) { // Padding byte is not zero, check if it is good to ignore it const ByteVector fourCcAfterPadding = readBlock(4); - if(isValidChunkName(fourCcAfterPadding)) { + if (isValidChunkName(fourCcAfterPadding)) { // Use the padding, it is followed by a valid chunk name. skipPadding = true; } } - if(skipPadding) { + if (skipPadding) { chunk.padding = 1; offset++; } @@ -347,24 +326,22 @@ void RIFF::File::read() } void RIFF::File::writeChunk(const ByteVector &name, const ByteVector &data, - unsigned long offset, unsigned long replace) -{ + unsigned long offset, unsigned long replace) { ByteVector combined; combined.append(name); combined.append(ByteVector::fromUInt(data.size(), d->endianness == BigEndian)); combined.append(data); - if(data.size() & 1) + if (data.size() & 1) combined.resize(combined.size() + 1, '\0'); insert(combined, offset, replace); } -void RIFF::File::updateGlobalSize() -{ +void RIFF::File::updateGlobalSize() { const Chunk first = d->chunks.front(); - const Chunk last = d->chunks.back(); + const Chunk last = d->chunks.back(); d->size = last.offset + last.size + last.padding - first.offset + 12; const ByteVector data = ByteVector::fromUInt(d->size, d->endianness == BigEndian); diff --git a/3rdparty/taglib/riff/rifffile.h b/3rdparty/taglib/riff/rifffile.h index 0000b3d11..46ff40ae2 100644 --- a/3rdparty/taglib/riff/rifffile.h +++ b/3rdparty/taglib/riff/rifffile.h @@ -32,87 +32,86 @@ namespace Strawberry_TagLib { namespace TagLib { - //! An implementation of TagLib::File with RIFF specific methods +//! An implementation of TagLib::File with RIFF specific methods - namespace RIFF { +namespace RIFF { - //! An RIFF file class with some useful methods specific to RIFF +//! An RIFF file class with some useful methods specific to RIFF - /*! +/*! * This implements the generic TagLib::File API and additionally provides * access to properties that are distinct to RIFF files, notably access * to the different ID3 tags. */ - class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File - { - public: - /*! +class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File { + public: + /*! * Destroys this instance of the File. */ - virtual ~File(); + virtual ~File(); - protected: + protected: + enum Endianness { BigEndian, + LittleEndian }; - enum Endianness { BigEndian, LittleEndian }; + File(FileName file, Endianness endianness); + File(IOStream *stream, Endianness endianness); - File(FileName file, Endianness endianness); - File(IOStream *stream, Endianness endianness); - - /*! + /*! * \return The size of the main RIFF chunk. */ - unsigned int riffSize() const; + unsigned int riffSize() const; - /*! + /*! * \return The number of chunks in the file. */ - unsigned int chunkCount() const; + unsigned int chunkCount() const; - /*! + /*! * \return The offset within the file for the selected chunk number. */ - unsigned int chunkOffset(unsigned int i) const; + unsigned int chunkOffset(unsigned int i) const; - /*! + /*! * \return The size of the chunk data. */ - unsigned int chunkDataSize(unsigned int i) const; + unsigned int chunkDataSize(unsigned int i) const; - /*! + /*! * \return The size of the padding after the chunk (can be either 0 or 1). */ - unsigned int chunkPadding(unsigned int i) const; + unsigned int chunkPadding(unsigned int i) const; - /*! + /*! * \return The name of the specified chunk, for instance, "COMM" or "ID3 " */ - ByteVector chunkName(unsigned int i) const; + ByteVector chunkName(unsigned int i) const; - /*! + /*! * Reads the chunk data from the file and returns it. * * \note This \e will move the read pointer for the file. */ - ByteVector chunkData(unsigned int i); + ByteVector chunkData(unsigned int i); - /*! + /*! * Sets the data for the specified chunk to \a data. * * \warning This will update the file immediately. */ - void setChunkData(unsigned int i, const ByteVector &data); + void setChunkData(unsigned int i, const ByteVector &data); - /*! + /*! * Sets the data for the chunk \a name to \a data. If a chunk with the * given name already exists it will be overwritten, otherwise it will be * created after the existing chunks. * * \warning This will update the file immediately. */ - void setChunkData(const ByteVector &name, const ByteVector &data); + void setChunkData(const ByteVector &name, const ByteVector &data); - /*! + /*! * Sets the data for the chunk \a name to \a data. If a chunk with the * given name already exists it will be overwritten, otherwise it will be * created after the existing chunks. @@ -123,41 +122,41 @@ namespace TagLib { * * \warning This will update the file immediately. */ - void setChunkData(const ByteVector &name, const ByteVector &data, bool alwaysCreate); + void setChunkData(const ByteVector &name, const ByteVector &data, bool alwaysCreate); - /*! + /*! * Removes the specified chunk. * * \warning This will update the file immediately. */ - void removeChunk(unsigned int i); + void removeChunk(unsigned int i); - /*! + /*! * Removes the chunk \a name. * * \warning This will update the file immediately. * \warning This removes all the chunks with the given name. */ - void removeChunk(const ByteVector &name); + void removeChunk(const ByteVector &name); - private: - File(const File &); - File &operator=(const File &); + private: + File(const File &); + File &operator=(const File &); - void read(); - void writeChunk(const ByteVector &name, const ByteVector &data, - unsigned long offset, unsigned long replace = 0); + void read(); + void writeChunk(const ByteVector &name, const ByteVector &data, + unsigned long offset, unsigned long replace = 0); - /*! + /*! * Update the global RIFF size based on the current internal structure. */ - void updateGlobalSize(); + void updateGlobalSize(); - class FilePrivate; - FilePrivate *d; - }; - } -} -} + class FilePrivate; + FilePrivate *d; +}; +} // namespace RIFF +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/riff/riffutils.h b/3rdparty/taglib/riff/riffutils.h index c297b6f7b..3eca4854e 100644 --- a/3rdparty/taglib/riff/riffutils.h +++ b/3rdparty/taglib/riff/riffutils.h @@ -31,31 +31,27 @@ #ifndef DO_NOT_DOCUMENT // tell Doxygen not to document this header namespace Strawberry_TagLib { -namespace TagLib -{ - namespace RIFF - { - namespace - { +namespace TagLib { +namespace RIFF { +namespace { - inline bool isValidChunkName(const ByteVector &name) - { - if(name.size() != 4) - return false; +inline bool isValidChunkName(const ByteVector &name) { + if (name.size() != 4) + return false; - for(ByteVector::ConstIterator it = name.begin(); it != name.end(); ++it) { - const int c = static_cast(*it); - if(c < 32 || 127 < c) - return false; - } - - return true; - } - - } + for (ByteVector::ConstIterator it = name.begin(); it != name.end(); ++it) { + const int c = static_cast(*it); + if (c < 32 || 127 < c) + return false; } + + return true; } -} + +} // namespace +} // namespace RIFF +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/riff/wav/infotag.cpp b/3rdparty/taglib/riff/wav/infotag.cpp index 761e80a2e..b81c251b0 100644 --- a/3rdparty/taglib/riff/wav/infotag.cpp +++ b/3rdparty/taglib/riff/wav/infotag.cpp @@ -32,15 +32,13 @@ using namespace Strawberry_TagLib::TagLib; using namespace RIFF::Info; -namespace -{ - const RIFF::Info::StringHandler defaultStringHandler; - const RIFF::Info::StringHandler *stringHandler = &defaultStringHandler; -} +namespace { +const RIFF::Info::StringHandler defaultStringHandler; +const RIFF::Info::StringHandler *stringHandler = &defaultStringHandler; +} // namespace -class RIFF::Info::Tag::TagPrivate -{ -public: +class RIFF::Info::Tag::TagPrivate { + public: FieldListMap fieldListMap; }; @@ -48,21 +46,17 @@ public: // StringHandler implementation //////////////////////////////////////////////////////////////////////////////// -StringHandler::StringHandler() -{ +StringHandler::StringHandler() { } -StringHandler::~StringHandler() -{ +StringHandler::~StringHandler() { } -String RIFF::Info::StringHandler::parse(const ByteVector &data) const -{ +String RIFF::Info::StringHandler::parse(const ByteVector &data) const { return String(data, String::UTF8); } -ByteVector RIFF::Info::StringHandler::render(const String &s) const -{ +ByteVector RIFF::Info::StringHandler::render(const String &s) const { return s.data(String::UTF8); } @@ -70,144 +64,119 @@ ByteVector RIFF::Info::StringHandler::render(const String &s) const // public members //////////////////////////////////////////////////////////////////////////////// -RIFF::Info::Tag::Tag(const ByteVector &data) : - Strawberry_TagLib::TagLib::Tag(), - d(new TagPrivate()) -{ +RIFF::Info::Tag::Tag(const ByteVector &data) : Strawberry_TagLib::TagLib::Tag(), + d(new TagPrivate()) { parse(data); } -RIFF::Info::Tag::Tag() : - Strawberry_TagLib::TagLib::Tag(), - d(new TagPrivate()) -{ +RIFF::Info::Tag::Tag() : Strawberry_TagLib::TagLib::Tag(), + d(new TagPrivate()) { } -RIFF::Info::Tag::~Tag() -{ +RIFF::Info::Tag::~Tag() { delete d; } -String RIFF::Info::Tag::title() const -{ +String RIFF::Info::Tag::title() const { return fieldText("INAM"); } -String RIFF::Info::Tag::artist() const -{ +String RIFF::Info::Tag::artist() const { return fieldText("IART"); } -String RIFF::Info::Tag::album() const -{ +String RIFF::Info::Tag::album() const { return fieldText("IPRD"); } -String RIFF::Info::Tag::comment() const -{ +String RIFF::Info::Tag::comment() const { return fieldText("ICMT"); } -String RIFF::Info::Tag::genre() const -{ +String RIFF::Info::Tag::genre() const { return fieldText("IGNR"); } -unsigned int RIFF::Info::Tag::year() const -{ +unsigned int RIFF::Info::Tag::year() const { return fieldText("ICRD").substr(0, 4).toInt(); } -unsigned int RIFF::Info::Tag::track() const -{ +unsigned int RIFF::Info::Tag::track() const { return fieldText("IPRT").toInt(); } -void RIFF::Info::Tag::setTitle(const String &s) -{ +void RIFF::Info::Tag::setTitle(const String &s) { setFieldText("INAM", s); } -void RIFF::Info::Tag::setArtist(const String &s) -{ +void RIFF::Info::Tag::setArtist(const String &s) { setFieldText("IART", s); } -void RIFF::Info::Tag::setAlbum(const String &s) -{ +void RIFF::Info::Tag::setAlbum(const String &s) { setFieldText("IPRD", s); } -void RIFF::Info::Tag::setComment(const String &s) -{ +void RIFF::Info::Tag::setComment(const String &s) { setFieldText("ICMT", s); } -void RIFF::Info::Tag::setGenre(const String &s) -{ +void RIFF::Info::Tag::setGenre(const String &s) { setFieldText("IGNR", s); } -void RIFF::Info::Tag::setYear(unsigned int i) -{ - if(i != 0) +void RIFF::Info::Tag::setYear(unsigned int i) { + if (i != 0) setFieldText("ICRD", String::number(i)); else d->fieldListMap.erase("ICRD"); } -void RIFF::Info::Tag::setTrack(unsigned int i) -{ - if(i != 0) +void RIFF::Info::Tag::setTrack(unsigned int i) { + if (i != 0) setFieldText("IPRT", String::number(i)); else d->fieldListMap.erase("IPRT"); } -bool RIFF::Info::Tag::isEmpty() const -{ +bool RIFF::Info::Tag::isEmpty() const { return d->fieldListMap.isEmpty(); } -FieldListMap RIFF::Info::Tag::fieldListMap() const -{ +FieldListMap RIFF::Info::Tag::fieldListMap() const { return d->fieldListMap; } -String RIFF::Info::Tag::fieldText(const ByteVector &id) const -{ - if(d->fieldListMap.contains(id)) +String RIFF::Info::Tag::fieldText(const ByteVector &id) const { + if (d->fieldListMap.contains(id)) return String(d->fieldListMap[id]); else return String(); } -void RIFF::Info::Tag::setFieldText(const ByteVector &id, const String &s) -{ +void RIFF::Info::Tag::setFieldText(const ByteVector &id, const String &s) { // id must be four-byte long pure ascii string. - if(!isValidChunkName(id)) + if (!isValidChunkName(id)) return; - if(!s.isEmpty()) + if (!s.isEmpty()) d->fieldListMap[id] = s; else removeField(id); } -void RIFF::Info::Tag::removeField(const ByteVector &id) -{ - if(d->fieldListMap.contains(id)) +void RIFF::Info::Tag::removeField(const ByteVector &id) { + if (d->fieldListMap.contains(id)) d->fieldListMap.erase(id); } -ByteVector RIFF::Info::Tag::render() const -{ +ByteVector RIFF::Info::Tag::render() const { ByteVector data("INFO"); FieldListMap::ConstIterator it = d->fieldListMap.begin(); - for(; it != d->fieldListMap.end(); ++it) { + for (; it != d->fieldListMap.end(); ++it) { ByteVector text = stringHandler->render(it->second); - if(text.isEmpty()) + if (text.isEmpty()) continue; data.append(it->first); @@ -216,18 +185,17 @@ ByteVector RIFF::Info::Tag::render() const do { data.append('\0'); - } while(data.size() & 1); + } while (data.size() & 1); } - if(data.size() == 4) + if (data.size() == 4) return ByteVector(); else return data; } -void RIFF::Info::Tag::setStringHandler(const StringHandler *handler) -{ - if(handler) +void RIFF::Info::Tag::setStringHandler(const StringHandler *handler) { + if (handler) stringHandler = handler; else stringHandler = &defaultStringHandler; @@ -237,16 +205,15 @@ void RIFF::Info::Tag::setStringHandler(const StringHandler *handler) // protected members //////////////////////////////////////////////////////////////////////////////// -void RIFF::Info::Tag::parse(const ByteVector &data) -{ +void RIFF::Info::Tag::parse(const ByteVector &data) { unsigned int p = 4; - while(p < data.size()) { + while (p < data.size()) { const unsigned int size = data.toUInt(p + 4, false); - if(size > data.size() - p - 8) + if (size > data.size() - p - 8) break; const ByteVector id = data.mid(p, 4); - if(isValidChunkName(id)) { + if (isValidChunkName(id)) { const String text = stringHandler->parse(data.mid(p + 8, size)); d->fieldListMap[id] = text; } diff --git a/3rdparty/taglib/riff/wav/infotag.h b/3rdparty/taglib/riff/wav/infotag.h index 1a0e61c47..f49749ce2 100644 --- a/3rdparty/taglib/riff/wav/infotag.h +++ b/3rdparty/taglib/riff/wav/infotag.h @@ -36,17 +36,17 @@ namespace Strawberry_TagLib { namespace TagLib { - class File; +class File; - //! A RIFF INFO tag implementation. - namespace RIFF { - namespace Info { +//! A RIFF INFO tag implementation. +namespace RIFF { +namespace Info { - typedef Map FieldListMap; +typedef Map FieldListMap; - //! A abstraction for the string to data encoding in Info tags. +//! A abstraction for the string to data encoding in Info tags. - /*! +/*! * RIFF INFO tag has no clear definitions about character encodings. * In practice, local encoding of each system is largely used and UTF-8 is * popular too. @@ -58,70 +58,68 @@ namespace TagLib { * \see ID3v1::Tag::setStringHandler() */ - class TAGLIB_EXPORT StringHandler - { - public: - StringHandler(); - ~StringHandler(); +class TAGLIB_EXPORT StringHandler { + public: + StringHandler(); + ~StringHandler(); - /*! + /*! * Decode a string from \a data. The default implementation assumes that * \a data is an UTF-8 character array. */ - virtual String parse(const ByteVector &data) const; + virtual String parse(const ByteVector &data) const; - /*! + /*! * Encode a ByteVector with the data from \a s. The default implementation * assumes that \a s is an UTF-8 string. */ - virtual ByteVector render(const String &s) const; - }; + virtual ByteVector render(const String &s) const; +}; - //! The main class in the ID3v2 implementation +//! The main class in the ID3v2 implementation - /*! +/*! * This is the main class in the INFO tag implementation. RIFF INFO tag is a * metadata format found in WAV audio and AVI video files. Though it is a part * of Microsoft/IBM's RIFF specification, the author could not find the official * documents about it. So, this implementation is referring to unofficial documents * online and some applications' behaviors especially Windows Explorer. */ - class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag - { - public: - /*! +class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag { + public: + /*! * Constructs an empty INFO tag. */ - Tag(); + Tag(); - /*! + /*! * Constructs an INFO tag read from \a data which is contents of "LIST" chunk. */ - Tag(const ByteVector &data); + Tag(const ByteVector &data); - virtual ~Tag(); + virtual ~Tag(); - // Reimplementations + // Reimplementations - virtual String title() const; - virtual String artist() const; - virtual String album() const; - virtual String comment() const; - virtual String genre() const; - virtual unsigned int year() const; - virtual unsigned int track() const; + virtual String title() const; + virtual String artist() const; + virtual String album() const; + virtual String comment() const; + virtual String genre() const; + virtual unsigned int year() const; + virtual unsigned int track() const; - virtual void setTitle(const String &s); - virtual void setArtist(const String &s); - virtual void setAlbum(const String &s); - virtual void setComment(const String &s); - virtual void setGenre(const String &s); - virtual void setYear(unsigned int i); - virtual void setTrack(unsigned int i); + virtual void setTitle(const String &s); + virtual void setArtist(const String &s); + virtual void setAlbum(const String &s); + virtual void setComment(const String &s); + virtual void setGenre(const String &s); + virtual void setYear(unsigned int i); + virtual void setTrack(unsigned int i); - virtual bool isEmpty() const; + virtual bool isEmpty() const; - /*! + /*! * Returns a copy of the internal fields of the tag. The returned map directly * reflects the contents of the "INFO" chunk. * @@ -131,14 +129,14 @@ namespace TagLib { * \see setFieldText() * \see removeField() */ - FieldListMap fieldListMap() const; + FieldListMap fieldListMap() const; - /* + /* * Gets the value of the field with the ID \a id. */ - String fieldText(const ByteVector &id) const; + String fieldText(const ByteVector &id) const; - /* + /* * Sets the value of the field with the ID \a id to \a s. * If the field does not exist, it is created. * If \s is empty, the field is removed. @@ -146,21 +144,21 @@ namespace TagLib { * \note fieldId must be four-byte long pure ASCII string. This function * performs nothing if fieldId is invalid. */ - void setFieldText(const ByteVector &id, const String &s); + void setFieldText(const ByteVector &id, const String &s); - /* + /* * Removes the field with the ID \a id. */ - void removeField(const ByteVector &id); + void removeField(const ByteVector &id); - /*! + /*! * Render the tag back to binary data, suitable to be written to disk. * * \note Returns empty ByteVector is the tag contains no fields. */ - ByteVector render() const; + ByteVector render() const; - /*! + /*! * Sets the string handler that decides how the text data will be * converted to and from binary data. * If the parameter \a handler is null, the previous handler is @@ -171,24 +169,25 @@ namespace TagLib { * * \see StringHandler */ - static void setStringHandler(const StringHandler *handler); + static void setStringHandler(const StringHandler *handler); - protected: - /*! + protected: + /*! * Pareses the body of the tag in \a data. */ - void parse(const ByteVector &data); + void parse(const ByteVector &data); - private: - Tag(const Tag &); - Tag &operator=(const Tag &); + private: + Tag(const Tag &); + Tag &operator=(const Tag &); - class TagPrivate; - TagPrivate *d; - }; - }} -} -} + class TagPrivate; + TagPrivate *d; +}; +} // namespace Info +} // namespace RIFF +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/riff/wav/wavfile.cpp b/3rdparty/taglib/riff/wav/wavfile.cpp index cc8d43279..9f89f6ce0 100644 --- a/3rdparty/taglib/riff/wav/wavfile.cpp +++ b/3rdparty/taglib/riff/wav/wavfile.cpp @@ -36,21 +36,18 @@ using namespace Strawberry_TagLib::TagLib; -namespace -{ - enum { ID3v2Index = 0, InfoIndex = 1 }; +namespace { +enum { ID3v2Index = 0, + InfoIndex = 1 }; } -class RIFF::WAV::File::FilePrivate -{ -public: - FilePrivate() : - properties(0), - hasID3v2(false), - hasInfo(false) {} +class RIFF::WAV::File::FilePrivate { + public: + FilePrivate() : properties(0), + hasID3v2(false), + hasInfo(false) {} - ~FilePrivate() - { + ~FilePrivate() { delete properties; } @@ -65,8 +62,7 @@ public: // static members //////////////////////////////////////////////////////////////////////////////// -bool RIFF::WAV::File::isSupported(IOStream *stream) -{ +bool RIFF::WAV::File::isSupported(IOStream *stream) { // A WAV file has to start with "RIFF????WAVE". const ByteVector id = Utils::readHeader(stream, 12, false); @@ -77,114 +73,98 @@ bool RIFF::WAV::File::isSupported(IOStream *stream) // public members //////////////////////////////////////////////////////////////////////////////// -RIFF::WAV::File::File(FileName file, bool readProperties, Properties::ReadStyle) : - RIFF::File(file, LittleEndian), - d(new FilePrivate()) -{ - if(isOpen()) +RIFF::WAV::File::File(FileName file, bool readProperties, Properties::ReadStyle) : RIFF::File(file, LittleEndian), + d(new FilePrivate()) { + if (isOpen()) read(readProperties); } -RIFF::WAV::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) : - RIFF::File(stream, LittleEndian), - d(new FilePrivate()) -{ - if(isOpen()) +RIFF::WAV::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) : RIFF::File(stream, LittleEndian), + d(new FilePrivate()) { + if (isOpen()) read(readProperties); } -RIFF::WAV::File::~File() -{ +RIFF::WAV::File::~File() { delete d; } -ID3v2::Tag *RIFF::WAV::File::tag() const -{ +ID3v2::Tag *RIFF::WAV::File::tag() const { return ID3v2Tag(); } -ID3v2::Tag *RIFF::WAV::File::ID3v2Tag() const -{ +ID3v2::Tag *RIFF::WAV::File::ID3v2Tag() const { return d->tag.access(ID3v2Index, false); } -RIFF::Info::Tag *RIFF::WAV::File::InfoTag() const -{ +RIFF::Info::Tag *RIFF::WAV::File::InfoTag() const { return d->tag.access(InfoIndex, false); } -void RIFF::WAV::File::strip(TagTypes tags) -{ +void RIFF::WAV::File::strip(TagTypes tags) { removeTagChunks(tags); - if(tags & ID3v2) + if (tags & ID3v2) d->tag.set(ID3v2Index, new ID3v2::Tag()); - if(tags & Info) + if (tags & Info) d->tag.set(InfoIndex, new RIFF::Info::Tag()); } -PropertyMap RIFF::WAV::File::properties() const -{ +PropertyMap RIFF::WAV::File::properties() const { return d->tag.properties(); } -void RIFF::WAV::File::removeUnsupportedProperties(const StringList &unsupported) -{ +void RIFF::WAV::File::removeUnsupportedProperties(const StringList &unsupported) { d->tag.removeUnsupportedProperties(unsupported); } -PropertyMap RIFF::WAV::File::setProperties(const PropertyMap &properties) -{ +PropertyMap RIFF::WAV::File::setProperties(const PropertyMap &properties) { InfoTag()->setProperties(properties); return ID3v2Tag()->setProperties(properties); } -RIFF::WAV::Properties *RIFF::WAV::File::audioProperties() const -{ +RIFF::WAV::Properties *RIFF::WAV::File::audioProperties() const { return d->properties; } -bool RIFF::WAV::File::save() -{ +bool RIFF::WAV::File::save() { return RIFF::WAV::File::save(AllTags); } -bool RIFF::WAV::File::save(TagTypes tags, bool stripOthers, int id3v2Version) -{ +bool RIFF::WAV::File::save(TagTypes tags, bool stripOthers, int id3v2Version) { return save(tags, - stripOthers ? StripOthers : StripNone, - id3v2Version == 3 ? ID3v2::v3 : ID3v2::v4); + stripOthers ? StripOthers : StripNone, + id3v2Version == 3 ? ID3v2::v3 : ID3v2::v4); } -bool RIFF::WAV::File::save(TagTypes tags, StripTags strip, ID3v2::Version version) -{ - if(readOnly()) { +bool RIFF::WAV::File::save(TagTypes tags, StripTags strip, ID3v2::Version version) { + if (readOnly()) { debug("RIFF::WAV::File::save() -- File is read only."); return false; } - if(!isValid()) { + if (!isValid()) { debug("RIFF::WAV::File::save() -- Trying to save invalid file."); return false; } - if(strip == StripOthers) + if (strip == StripOthers) File::strip(static_cast(AllTags & ~tags)); - if(tags & ID3v2) { + if (tags & ID3v2) { removeTagChunks(ID3v2); - if(ID3v2Tag() && !ID3v2Tag()->isEmpty()) { + if (ID3v2Tag() && !ID3v2Tag()->isEmpty()) { setChunkData("ID3 ", ID3v2Tag()->render(version)); d->hasID3v2 = true; } } - if(tags & Info) { + if (tags & Info) { removeTagChunks(Info); - if(InfoTag() && !InfoTag()->isEmpty()) { + if (InfoTag() && !InfoTag()->isEmpty()) { setChunkData("LIST", InfoTag()->render(), true); d->hasInfo = true; } @@ -193,13 +173,11 @@ bool RIFF::WAV::File::save(TagTypes tags, StripTags strip, ID3v2::Version versio return true; } -bool RIFF::WAV::File::hasID3v2Tag() const -{ +bool RIFF::WAV::File::hasID3v2Tag() const { return d->hasID3v2; } -bool RIFF::WAV::File::hasInfoTag() const -{ +bool RIFF::WAV::File::hasInfoTag() const { return d->hasInfo; } @@ -207,12 +185,11 @@ bool RIFF::WAV::File::hasInfoTag() const // private members //////////////////////////////////////////////////////////////////////////////// -void RIFF::WAV::File::read(bool readProperties) -{ - for(unsigned int i = 0; i < chunkCount(); ++i) { +void RIFF::WAV::File::read(bool readProperties) { + for (unsigned int i = 0; i < chunkCount(); ++i) { const ByteVector name = chunkName(i); - if(name == "ID3 " || name == "id3 ") { - if(!d->tag[ID3v2Index]) { + if (name == "ID3 " || name == "id3 ") { + if (!d->tag[ID3v2Index]) { d->tag.set(ID3v2Index, new ID3v2::Tag(this, chunkOffset(i))); d->hasID3v2 = true; } @@ -220,10 +197,10 @@ void RIFF::WAV::File::read(bool readProperties) debug("RIFF::WAV::File::read() - Duplicate ID3v2 tag found."); } } - else if(name == "LIST") { + else if (name == "LIST") { const ByteVector data = chunkData(i); - if(data.startsWith("INFO")) { - if(!d->tag[InfoIndex]) { + if (data.startsWith("INFO")) { + if (!d->tag[InfoIndex]) { d->tag.set(InfoIndex, new RIFF::Info::Tag(data)); d->hasInfo = true; } @@ -234,28 +211,27 @@ void RIFF::WAV::File::read(bool readProperties) } } - if(!d->tag[ID3v2Index]) + if (!d->tag[ID3v2Index]) d->tag.set(ID3v2Index, new ID3v2::Tag()); - if(!d->tag[InfoIndex]) + if (!d->tag[InfoIndex]) d->tag.set(InfoIndex, new RIFF::Info::Tag()); - if(readProperties) + if (readProperties) d->properties = new Properties(this, Properties::Average); } -void RIFF::WAV::File::removeTagChunks(TagTypes tags) -{ - if((tags & ID3v2) && d->hasID3v2) { +void RIFF::WAV::File::removeTagChunks(TagTypes tags) { + if ((tags & ID3v2) && d->hasID3v2) { removeChunk("ID3 "); removeChunk("id3 "); d->hasID3v2 = false; } - if((tags & Info) && d->hasInfo) { - for(int i = static_cast(chunkCount()) - 1; i >= 0; --i) { - if(chunkName(i) == "LIST" && chunkData(i).startsWith("INFO")) + if ((tags & Info) && d->hasInfo) { + for (int i = static_cast(chunkCount()) - 1; i >= 0; --i) { + if (chunkName(i) == "LIST" && chunkData(i).startsWith("INFO")) removeChunk(i); } diff --git a/3rdparty/taglib/riff/wav/wavfile.h b/3rdparty/taglib/riff/wav/wavfile.h index a6745ebf5..fa3021901 100644 --- a/3rdparty/taglib/riff/wav/wavfile.h +++ b/3rdparty/taglib/riff/wav/wavfile.h @@ -34,52 +34,51 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace RIFF { +namespace RIFF { - //! An implementation of WAV metadata +//! An implementation of WAV metadata - /*! +/*! * This is implementation of WAV metadata. * * This supports an ID3v2 tag as well as reading stream from the ID3 RIFF * chunk as well as properties from the file. */ - namespace WAV { +namespace WAV { - //! An implementation of TagLib::File with WAV specific methods +//! An implementation of TagLib::File with WAV specific methods - /*! +/*! * This implements and provides an interface for WAV files to the * TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing * the abstract TagLib::File API as well as providing some additional * information specific to WAV files. */ - class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::RIFF::File - { - public: - enum TagTypes { - //! Empty set. Matches no tag types. - NoTags = 0x0000, - //! Matches ID3v2 tags. - ID3v2 = 0x0001, - //! Matches INFO tags. - Info = 0x0002, - //! Matches all tag types. - AllTags = 0xffff - }; +class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::RIFF::File { + public: + enum TagTypes { + //! Empty set. Matches no tag types. + NoTags = 0x0000, + //! Matches ID3v2 tags. + ID3v2 = 0x0001, + //! Matches INFO tags. + Info = 0x0002, + //! Matches all tag types. + AllTags = 0xffff + }; - /*! + /*! * Constructs a WAV file from \a file. If \a readProperties is true the * file's audio properties will also be read. * * \note In the current implementation, \a propertiesStyle is ignored. */ - File(FileName file, bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(FileName file, bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Constructs a WAV file from \a stream. If \a readProperties is true the * file's audio properties will also be read. * @@ -88,23 +87,23 @@ namespace TagLib { * * \note In the current implementation, \a propertiesStyle is ignored. */ - File(IOStream *stream, bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(IOStream *stream, bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Destroys this instance of the File. */ - virtual ~File(); + virtual ~File(); - /*! + /*! * Returns the ID3v2 Tag for this file. * * \note This method does not return all the tags for this file for * backward compatibility. Will be fixed in TagLib 2.0. */ - ID3v2::Tag *tag() const; + ID3v2::Tag *tag() const; - /*! + /*! * Returns the ID3v2 Tag for this file. * * \note This always returns a valid pointer regardless of whether or not @@ -113,9 +112,9 @@ namespace TagLib { * * \see hasID3v2Tag() */ - ID3v2::Tag *ID3v2Tag() const; + ID3v2::Tag *ID3v2Tag() const; - /*! + /*! * Returns the RIFF INFO Tag for this file. * * \note This always returns a valid pointer regardless of whether or not @@ -124,94 +123,94 @@ namespace TagLib { * * \see hasInfoTag() */ - Info::Tag *InfoTag() const; + Info::Tag *InfoTag() const; - /*! + /*! * This will strip the tags that match the OR-ed together TagTypes from the * file. By default it strips all tags. It returns true if the tags are * successfully stripped. * * \note This will update the file immediately. */ - void strip(TagTypes tags = AllTags); + void strip(TagTypes tags = AllTags); - /*! + /*! * Implements the unified property interface -- export function. * This method forwards to ID3v2::Tag::properties(). */ - PropertyMap properties() const; + PropertyMap properties() const; - void removeUnsupportedProperties(const StringList &properties); + void removeUnsupportedProperties(const StringList &properties); - /*! + /*! * Implements the unified property interface -- import function. * This method forwards to ID3v2::Tag::setProperties(). */ - PropertyMap setProperties(const PropertyMap &); + PropertyMap setProperties(const PropertyMap &); - /*! + /*! * Returns the WAV::Properties for this file. If no audio properties * were read then this will return a null pointer. */ - virtual Properties *audioProperties() const; + virtual Properties *audioProperties() const; - /*! + /*! * Saves the file. */ - virtual bool save(); + virtual bool save(); - /*! + /*! * \deprecated */ - TAGLIB_DEPRECATED bool save(TagTypes tags, bool stripOthers, int id3v2Version = 4); + TAGLIB_DEPRECATED bool save(TagTypes tags, bool stripOthers, int id3v2Version = 4); - /*! + /*! * Save the file. If \a strip is specified, it is possible to choose if * tags not specified in \a tags should be stripped from the file or * retained. With \a version, it is possible to specify whether ID3v2.4 * or ID3v2.3 should be used. */ - bool save(TagTypes tags, StripTags strip = StripOthers, - ID3v2::Version version = ID3v2::v4); + bool save(TagTypes tags, StripTags strip = StripOthers, + ID3v2::Version version = ID3v2::v4); - /*! + /*! * Returns whether or not the file on disk actually has an ID3v2 tag. * * \see ID3v2Tag() */ - bool hasID3v2Tag() const; + bool hasID3v2Tag() const; - /*! + /*! * Returns whether or not the file on disk actually has a RIFF INFO tag. * * \see InfoTag() */ - bool hasInfoTag() const; + bool hasInfoTag() const; - /*! + /*! * Returns whether or not the given \a stream can be opened as a WAV * file. * * \note This method is designed to do a quick check. The result may * not necessarily be correct. */ - static bool isSupported(IOStream *stream); + static bool isSupported(IOStream *stream); - private: - File(const File &); - File &operator=(const File &); + private: + File(const File &); + File &operator=(const File &); - void read(bool readProperties); - void removeTagChunks(TagTypes tags); + void read(bool readProperties); + void removeTagChunks(TagTypes tags); - friend class Properties; + friend class Properties; - class FilePrivate; - FilePrivate *d; - }; - } - } -} -} + class FilePrivate; + FilePrivate *d; +}; +} // namespace WAV +} // namespace RIFF +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/riff/wav/wavproperties.cpp b/3rdparty/taglib/riff/wav/wavproperties.cpp index 0730b57bb..017fd3413 100644 --- a/3rdparty/taglib/riff/wav/wavproperties.cpp +++ b/3rdparty/taglib/riff/wav/wavproperties.cpp @@ -29,27 +29,23 @@ using namespace Strawberry_TagLib::TagLib; -namespace -{ - // Quoted from RFC 2361. - enum WaveFormat - { - FORMAT_UNKNOWN = 0x0000, - FORMAT_PCM = 0x0001 - }; -} +namespace { +// Quoted from RFC 2361. +enum WaveFormat { + FORMAT_UNKNOWN = 0x0000, + FORMAT_PCM = 0x0001 +}; +} // namespace -class RIFF::WAV::Properties::PropertiesPrivate -{ -public: - PropertiesPrivate() : - format(0), - length(0), - bitrate(0), - sampleRate(0), - channels(0), - bitsPerSample(0), - sampleFrames(0) {} +class RIFF::WAV::Properties::PropertiesPrivate { + public: + PropertiesPrivate() : format(0), + length(0), + bitrate(0), + sampleRate(0), + channels(0), + bitsPerSample(0), + sampleFrames(0) {} int format; int length; @@ -64,79 +60,62 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -RIFF::WAV::Properties::Properties(const ByteVector &, ReadStyle style) : - AudioProperties(style), - d(new PropertiesPrivate()) -{ +RIFF::WAV::Properties::Properties(const ByteVector &, ReadStyle style) : AudioProperties(style), + d(new PropertiesPrivate()) { debug("RIFF::WAV::Properties::Properties() -- This constructor is no longer used."); } -RIFF::WAV::Properties::Properties(const ByteVector &, unsigned int, ReadStyle style) : - AudioProperties(style), - d(new PropertiesPrivate()) -{ +RIFF::WAV::Properties::Properties(const ByteVector &, unsigned int, ReadStyle style) : AudioProperties(style), + d(new PropertiesPrivate()) { debug("RIFF::WAV::Properties::Properties() -- This constructor is no longer used."); } -Strawberry_TagLib::TagLib::RIFF::WAV::Properties::Properties(File *file, ReadStyle style) : - AudioProperties(style), - d(new PropertiesPrivate()) -{ +Strawberry_TagLib::TagLib::RIFF::WAV::Properties::Properties(File *file, ReadStyle style) : AudioProperties(style), + d(new PropertiesPrivate()) { read(file); } -RIFF::WAV::Properties::~Properties() -{ +RIFF::WAV::Properties::~Properties() { delete d; } -int RIFF::WAV::Properties::length() const -{ +int RIFF::WAV::Properties::length() const { return lengthInSeconds(); } -int RIFF::WAV::Properties::lengthInSeconds() const -{ +int RIFF::WAV::Properties::lengthInSeconds() const { return d->length / 1000; } -int RIFF::WAV::Properties::lengthInMilliseconds() const -{ +int RIFF::WAV::Properties::lengthInMilliseconds() const { return d->length; } -int RIFF::WAV::Properties::bitrate() const -{ +int RIFF::WAV::Properties::bitrate() const { return d->bitrate; } -int RIFF::WAV::Properties::sampleRate() const -{ +int RIFF::WAV::Properties::sampleRate() const { return d->sampleRate; } -int RIFF::WAV::Properties::channels() const -{ +int RIFF::WAV::Properties::channels() const { return d->channels; } -int RIFF::WAV::Properties::bitsPerSample() const -{ +int RIFF::WAV::Properties::bitsPerSample() const { return d->bitsPerSample; } -int RIFF::WAV::Properties::sampleWidth() const -{ +int RIFF::WAV::Properties::sampleWidth() const { return bitsPerSample(); } -unsigned int RIFF::WAV::Properties::sampleFrames() const -{ +unsigned int RIFF::WAV::Properties::sampleFrames() const { return d->sampleFrames; } -int RIFF::WAV::Properties::format() const -{ +int RIFF::WAV::Properties::format() const { return d->format; } @@ -144,68 +123,67 @@ int RIFF::WAV::Properties::format() const // private members //////////////////////////////////////////////////////////////////////////////// -void RIFF::WAV::Properties::read(File *file) -{ +void RIFF::WAV::Properties::read(File *file) { ByteVector data; unsigned int streamLength = 0; unsigned int totalSamples = 0; - for(unsigned int i = 0; i < file->chunkCount(); ++i) { + for (unsigned int i = 0; i < file->chunkCount(); ++i) { const ByteVector name = file->chunkName(i); - if(name == "fmt ") { - if(data.isEmpty()) + if (name == "fmt ") { + if (data.isEmpty()) data = file->chunkData(i); else debug("RIFF::WAV::Properties::read() - Duplicate 'fmt ' chunk found."); } - else if(name == "data") { - if(streamLength == 0) + else if (name == "data") { + if (streamLength == 0) streamLength = file->chunkDataSize(i) + file->chunkPadding(i); else debug("RIFF::WAV::Properties::read() - Duplicate 'data' chunk found."); } - else if(name == "fact") { - if(totalSamples == 0) + else if (name == "fact") { + if (totalSamples == 0) totalSamples = file->chunkData(i).toUInt(0, false); else debug("RIFF::WAV::Properties::read() - Duplicate 'fact' chunk found."); } } - if(data.size() < 16) { + if (data.size() < 16) { debug("RIFF::WAV::Properties::read() - 'fmt ' chunk not found or too short."); return; } - if(streamLength == 0) { + if (streamLength == 0) { debug("RIFF::WAV::Properties::read() - 'data' chunk not found."); return; } d->format = data.toShort(0, false); - if(d->format != FORMAT_PCM && totalSamples == 0) { + if (d->format != FORMAT_PCM && totalSamples == 0) { debug("RIFF::WAV::Properties::read() - Non-PCM format, but 'fact' chunk not found."); return; } - d->channels = data.toShort(2, false); - d->sampleRate = data.toUInt(4, false); + d->channels = data.toShort(2, false); + d->sampleRate = data.toUInt(4, false); d->bitsPerSample = data.toShort(14, false); - if(d->format != FORMAT_PCM) + if (d->format != FORMAT_PCM) d->sampleFrames = totalSamples; - else if(d->channels > 0 && d->bitsPerSample > 0) + else if (d->channels > 0 && d->bitsPerSample > 0) d->sampleFrames = streamLength / (d->channels * ((d->bitsPerSample + 7) / 8)); - if(d->sampleFrames > 0 && d->sampleRate > 0) { + if (d->sampleFrames > 0 && d->sampleRate > 0) { const double length = d->sampleFrames * 1000.0 / d->sampleRate; - d->length = static_cast(length + 0.5); + d->length = static_cast(length + 0.5); d->bitrate = static_cast(streamLength * 8.0 / length + 0.5); } else { const unsigned int byteRate = data.toUInt(8, false); - if(byteRate > 0) { - d->length = static_cast(streamLength * 1000.0 / byteRate + 0.5); + if (byteRate > 0) { + d->length = static_cast(streamLength * 1000.0 / byteRate + 0.5); d->bitrate = static_cast(byteRate * 8.0 / 1000.0 + 0.5); } } diff --git a/3rdparty/taglib/riff/wav/wavproperties.h b/3rdparty/taglib/riff/wav/wavproperties.h index 004312606..1795cdcb6 100644 --- a/3rdparty/taglib/riff/wav/wavproperties.h +++ b/3rdparty/taglib/riff/wav/wavproperties.h @@ -32,52 +32,51 @@ namespace Strawberry_TagLib { namespace TagLib { - class ByteVector; +class ByteVector; - namespace RIFF { +namespace RIFF { - namespace WAV { +namespace WAV { - class File; +class File; - //! An implementation of audio property reading for WAV +//! An implementation of audio property reading for WAV - /*! +/*! * This reads the data from an WAV stream found in the AudioProperties * API. */ - class TAGLIB_EXPORT Properties : public AudioProperties - { - public: - /*! +class TAGLIB_EXPORT Properties : public AudioProperties { + public: + /*! * Create an instance of WAV::Properties with the data read from the * ByteVector \a data. * * \deprecated */ - TAGLIB_DEPRECATED Properties(const ByteVector &data, ReadStyle style); + TAGLIB_DEPRECATED Properties(const ByteVector &data, ReadStyle style); - /*! + /*! * Create an instance of WAV::Properties with the data read from the * ByteVector \a data and the length calculated using \a streamLength. * * \deprecated */ - TAGLIB_DEPRECATED Properties(const ByteVector &data, unsigned int streamLength, ReadStyle style); + TAGLIB_DEPRECATED Properties(const ByteVector &data, unsigned int streamLength, ReadStyle style); - /*! + /*! * Create an instance of WAV::Properties with the data read from the * WAV::File \a file. */ - Properties(File *file, ReadStyle style); + Properties(File *file, ReadStyle style); - /*! + /*! * Destroys this WAV::Properties instance. */ - virtual ~Properties(); + virtual ~Properties(); - /*! + /*! * Returns the length of the file in seconds. The length is rounded down to * the nearest whole second. * @@ -85,60 +84,60 @@ namespace TagLib { * * \deprecated */ - TAGLIB_DEPRECATED virtual int length() const; + TAGLIB_DEPRECATED virtual int length() const; - /*! + /*! * Returns the length of the file in seconds. The length is rounded down to * the nearest whole second. * * \see lengthInMilliseconds() */ - // BIC: make virtual - int lengthInSeconds() const; + // BIC: make virtual + int lengthInSeconds() const; - /*! + /*! * Returns the length of the file in milliseconds. * * \see lengthInSeconds() */ - // BIC: make virtual - int lengthInMilliseconds() const; + // BIC: make virtual + int lengthInMilliseconds() const; - /*! + /*! * Returns the average bit rate of the file in kb/s. */ - virtual int bitrate() const; + virtual int bitrate() const; - /*! + /*! * Returns the sample rate in Hz. */ - virtual int sampleRate() const; + virtual int sampleRate() const; - /*! + /*! * Returns the number of audio channels. */ - virtual int channels() const; + virtual int channels() const; - /*! + /*! * Returns the number of bits per audio sample. */ - int bitsPerSample() const; + int bitsPerSample() const; - /*! + /*! * Returns the number of bits per audio sample. * * \note This method is just an alias of bitsPerSample(). * * \deprecated */ - TAGLIB_DEPRECATED int sampleWidth() const; + TAGLIB_DEPRECATED int sampleWidth() const; - /*! + /*! * Returns the number of sample frames. */ - unsigned int sampleFrames() const; + unsigned int sampleFrames() const; - /*! + /*! * Returns the format ID of the file. * 0 for unknown, 1 for PCM, 2 for ADPCM, 3 for 32/64-bit IEEE754, and * so forth. @@ -146,20 +145,20 @@ namespace TagLib { * \note For further information, refer to the WAVE Form Registration * Numbers in RFC 2361. */ - int format() const; + int format() const; - private: - Properties(const Properties &); - Properties &operator=(const Properties &); + private: + Properties(const Properties &); + Properties &operator=(const Properties &); - void read(File *file); + void read(File *file); - class PropertiesPrivate; - PropertiesPrivate *d; - }; - } - } -} -} + class PropertiesPrivate; + PropertiesPrivate *d; +}; +} // namespace WAV +} // namespace RIFF +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/s3m/s3mfile.cpp b/3rdparty/taglib/s3m/s3mfile.cpp index 5d938f111..ad3353c16 100644 --- a/3rdparty/taglib/s3m/s3mfile.cpp +++ b/3rdparty/taglib/s3m/s3mfile.cpp @@ -35,64 +35,52 @@ using namespace Strawberry_TagLib::TagLib; using namespace S3M; -class S3M::File::FilePrivate -{ -public: +class S3M::File::FilePrivate { + public: explicit FilePrivate(AudioProperties::ReadStyle propertiesStyle) - : properties(propertiesStyle) - { + : properties(propertiesStyle) { } - Mod::Tag tag; + Mod::Tag tag; S3M::Properties properties; }; S3M::File::File(FileName file, bool readProperties, - AudioProperties::ReadStyle propertiesStyle) : - Mod::FileBase(file), - d(new FilePrivate(propertiesStyle)) -{ - if(isOpen()) + AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(file), + d(new FilePrivate(propertiesStyle)) { + if (isOpen()) read(readProperties); } S3M::File::File(IOStream *stream, bool readProperties, - AudioProperties::ReadStyle propertiesStyle) : - Mod::FileBase(stream), - d(new FilePrivate(propertiesStyle)) -{ - if(isOpen()) + AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(stream), + d(new FilePrivate(propertiesStyle)) { + if (isOpen()) read(readProperties); } -S3M::File::~File() -{ +S3M::File::~File() { delete d; } -Mod::Tag *S3M::File::tag() const -{ +Mod::Tag *S3M::File::tag() const { return &d->tag; } -PropertyMap S3M::File::properties() const -{ +PropertyMap S3M::File::properties() const { return d->tag.properties(); } -PropertyMap S3M::File::setProperties(const PropertyMap &properties) -{ +PropertyMap S3M::File::setProperties(const PropertyMap &properties) { return d->tag.setProperties(properties); } -S3M::Properties *S3M::File::audioProperties() const -{ +S3M::Properties *S3M::File::audioProperties() const { return &d->properties; } -bool S3M::File::save() -{ - if(readOnly()) { +bool S3M::File::save() { + if (readOnly()) { debug("S3M::File::save() - Cannot save to a read only file."); return false; } @@ -108,35 +96,35 @@ bool S3M::File::save() unsigned short length = 0; unsigned short sampleCount = 0; - if(!readU16L(length) || !readU16L(sampleCount)) + if (!readU16L(length) || !readU16L(sampleCount)) return false; seek(28, Current); int channels = 0; - for(int i = 0; i < 32; ++ i) { + for (int i = 0; i < 32; ++i) { unsigned char setting = 0; - if(!readByte(setting)) + if (!readByte(setting)) return false; // or if(setting >= 128)? // or channels = i + 1;? // need a better spec! - if(setting != 0xff) ++ channels; + if (setting != 0xff) ++channels; } seek(channels, Current); StringList lines = d->tag.comment().split("\n"); // write comment as sample names: - for(unsigned short i = 0; i < sampleCount; ++ i) { + for (unsigned short i = 0; i < sampleCount; ++i) { seek(96L + length + ((long)i << 1)); unsigned short instrumentOffset = 0; - if(!readU16L(instrumentOffset)) + if (!readU16L(instrumentOffset)) return false; seek(((long)instrumentOffset << 4) + 48); - if(i < lines.size()) + if (i < lines.size()) writeString(lines[i], 27); else writeString(String(), 27); @@ -146,9 +134,8 @@ bool S3M::File::save() return true; } -void S3M::File::read(bool) -{ - if(!isOpen()) +void S3M::File::read(bool) { + if (!isOpen()) return; READ_STRING(d->tag.setTitle, 28); @@ -188,21 +175,21 @@ void S3M::File::read(bool) seek(12, Current); int channels = 0; - for(int i = 0; i < 32; ++ i) { + for (int i = 0; i < 32; ++i) { READ_BYTE_AS(setting); // or if(setting >= 128)? // or channels = i + 1;? // need a better spec! - if(setting != 0xff) ++ channels; + if (setting != 0xff) ++channels; } d->properties.setChannels(channels); seek(96); unsigned short realLength = 0; - for(unsigned short i = 0; i < length; ++ i) { + for (unsigned short i = 0; i < length; ++i) { READ_BYTE_AS(order); - if(order == 255) break; - if(order != 254) ++ realLength; + if (order == 255) break; + if (order != 254) ++realLength; } d->properties.setLengthInPatterns(realLength); @@ -213,7 +200,7 @@ void S3M::File::read(bool) // However, there I never found instruments (SCRI) but // instead samples (SCRS). StringList comment; - for(unsigned short i = 0; i < sampleCount; ++ i) { + for (unsigned short i = 0; i < sampleCount; ++i) { seek(96L + length + ((long)i << 1)); READ_U16L_AS(sampleHeaderOffset); diff --git a/3rdparty/taglib/s3m/s3mfile.h b/3rdparty/taglib/s3m/s3mfile.h index 7112a1471..96846ef33 100644 --- a/3rdparty/taglib/s3m/s3mfile.h +++ b/3rdparty/taglib/s3m/s3mfile.h @@ -36,22 +36,22 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace S3M { +namespace S3M { - class TAGLIB_EXPORT File : public Mod::FileBase { - public: - /*! +class TAGLIB_EXPORT File : public Mod::FileBase { + public: + /*! * Constructs a ScreamTracker III from \a file. * * \note In the current implementation, both \a readProperties and * \a propertiesStyle are ignored. The audio properties are always * read. */ - File(FileName file, bool readProperties = true, - AudioProperties::ReadStyle propertiesStyle = - AudioProperties::Average); + File(FileName file, bool readProperties = true, + AudioProperties::ReadStyle propertiesStyle = + AudioProperties::Average); - /*! + /*! * Constructs a ScreamTracker III file from \a stream. * * \note In the current implementation, both \a readProperties and @@ -61,54 +61,54 @@ namespace TagLib { * \note TagLib will *not* take ownership of the stream, the caller is * responsible for deleting it after the File object. */ - File(IOStream *stream, bool readProperties = true, - AudioProperties::ReadStyle propertiesStyle = - AudioProperties::Average); + File(IOStream *stream, bool readProperties = true, + AudioProperties::ReadStyle propertiesStyle = + AudioProperties::Average); - /*! + /*! * Destroys this instance of the File. */ - virtual ~File(); + virtual ~File(); - Mod::Tag *tag() const; + Mod::Tag *tag() const; - /*! + /*! * Implements the unified property interface -- export function. * Forwards to Mod::Tag::properties(). */ - PropertyMap properties() const; + PropertyMap properties() const; - /*! + /*! * Implements the unified property interface -- import function. * Forwards to Mod::Tag::setProperties(). */ - PropertyMap setProperties(const PropertyMap &); + PropertyMap setProperties(const PropertyMap &); - /*! + /*! * Returns the S3M::Properties for this file. If no audio properties * were read then this will return a null pointer. */ - S3M::Properties *audioProperties() const; + S3M::Properties *audioProperties() const; - /*! + /*! * Save the file. * This is the same as calling save(AllTags); * * \note Saving ScreamTracker III tags is not supported. */ - bool save(); + bool save(); - private: - File(const File &); - File &operator=(const File &); + private: + File(const File &); + File &operator=(const File &); - void read(bool readProperties); + void read(bool readProperties); - class FilePrivate; - FilePrivate *d; - }; - } -} -} + class FilePrivate; + FilePrivate *d; +}; +} // namespace S3M +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/s3m/s3mproperties.cpp b/3rdparty/taglib/s3m/s3mproperties.cpp index 505fb894e..ddeaeb145 100644 --- a/3rdparty/taglib/s3m/s3mproperties.cpp +++ b/3rdparty/taglib/s3m/s3mproperties.cpp @@ -29,191 +29,156 @@ using namespace Strawberry_TagLib::TagLib; using namespace S3M; -class S3M::Properties::PropertiesPrivate -{ -public: - PropertiesPrivate() : - lengthInPatterns(0), - channels(0), - stereo(false), - sampleCount(0), - patternCount(0), - flags(0), - trackerVersion(0), - fileFormatVersion(0), - globalVolume(0), - masterVolume(0), - tempo(0), - bpmSpeed(0) - { +class S3M::Properties::PropertiesPrivate { + public: + PropertiesPrivate() : lengthInPatterns(0), + channels(0), + stereo(false), + sampleCount(0), + patternCount(0), + flags(0), + trackerVersion(0), + fileFormatVersion(0), + globalVolume(0), + masterVolume(0), + tempo(0), + bpmSpeed(0) { } unsigned short lengthInPatterns; - int channels; - bool stereo; + int channels; + bool stereo; unsigned short sampleCount; unsigned short patternCount; unsigned short flags; unsigned short trackerVersion; unsigned short fileFormatVersion; - unsigned char globalVolume; - unsigned char masterVolume; - unsigned char tempo; - unsigned char bpmSpeed; + unsigned char globalVolume; + unsigned char masterVolume; + unsigned char tempo; + unsigned char bpmSpeed; }; -S3M::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) : - AudioProperties(propertiesStyle), - d(new PropertiesPrivate()) -{ +S3M::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) : AudioProperties(propertiesStyle), + d(new PropertiesPrivate()) { } -S3M::Properties::~Properties() -{ +S3M::Properties::~Properties() { delete d; } -int S3M::Properties::length() const -{ +int S3M::Properties::length() const { return 0; } -int S3M::Properties::lengthInSeconds() const -{ +int S3M::Properties::lengthInSeconds() const { return 0; } -int S3M::Properties::lengthInMilliseconds() const -{ +int S3M::Properties::lengthInMilliseconds() const { return 0; } -int S3M::Properties::bitrate() const -{ +int S3M::Properties::bitrate() const { return 0; } -int S3M::Properties::sampleRate() const -{ +int S3M::Properties::sampleRate() const { return 0; } -int S3M::Properties::channels() const -{ +int S3M::Properties::channels() const { return d->channels; } -unsigned short S3M::Properties::lengthInPatterns() const -{ +unsigned short S3M::Properties::lengthInPatterns() const { return d->lengthInPatterns; } -bool S3M::Properties::stereo() const -{ +bool S3M::Properties::stereo() const { return d->stereo; } -unsigned short S3M::Properties::sampleCount() const -{ +unsigned short S3M::Properties::sampleCount() const { return d->sampleCount; } -unsigned short S3M::Properties::patternCount() const -{ +unsigned short S3M::Properties::patternCount() const { return d->patternCount; } -unsigned short S3M::Properties::flags() const -{ +unsigned short S3M::Properties::flags() const { return d->flags; } -unsigned short S3M::Properties::trackerVersion() const -{ +unsigned short S3M::Properties::trackerVersion() const { return d->trackerVersion; } -unsigned short S3M::Properties::fileFormatVersion() const -{ +unsigned short S3M::Properties::fileFormatVersion() const { return d->fileFormatVersion; } -unsigned char S3M::Properties::globalVolume() const -{ +unsigned char S3M::Properties::globalVolume() const { return d->globalVolume; } -unsigned char S3M::Properties::masterVolume() const -{ +unsigned char S3M::Properties::masterVolume() const { return d->masterVolume; } -unsigned char S3M::Properties::tempo() const -{ +unsigned char S3M::Properties::tempo() const { return d->tempo; } -unsigned char S3M::Properties::bpmSpeed() const -{ +unsigned char S3M::Properties::bpmSpeed() const { return d->bpmSpeed; } -void S3M::Properties::setLengthInPatterns(unsigned short lengthInPatterns) -{ +void S3M::Properties::setLengthInPatterns(unsigned short lengthInPatterns) { d->lengthInPatterns = lengthInPatterns; } -void S3M::Properties::setChannels(int channels) -{ +void S3M::Properties::setChannels(int channels) { d->channels = channels; } -void S3M::Properties::setStereo(bool stereo) -{ +void S3M::Properties::setStereo(bool stereo) { d->stereo = stereo; } -void S3M::Properties::setSampleCount(unsigned short sampleCount) -{ +void S3M::Properties::setSampleCount(unsigned short sampleCount) { d->sampleCount = sampleCount; } -void S3M::Properties::setPatternCount(unsigned short patternCount) -{ +void S3M::Properties::setPatternCount(unsigned short patternCount) { d->patternCount = patternCount; } -void S3M::Properties::setFlags(unsigned short flags) -{ +void S3M::Properties::setFlags(unsigned short flags) { d->flags = flags; } -void S3M::Properties::setTrackerVersion(unsigned short trackerVersion) -{ +void S3M::Properties::setTrackerVersion(unsigned short trackerVersion) { d->trackerVersion = trackerVersion; } -void S3M::Properties::setFileFormatVersion(unsigned short fileFormatVersion) -{ +void S3M::Properties::setFileFormatVersion(unsigned short fileFormatVersion) { d->fileFormatVersion = fileFormatVersion; } -void S3M::Properties::setGlobalVolume(unsigned char globalVolume) -{ +void S3M::Properties::setGlobalVolume(unsigned char globalVolume) { d->globalVolume = globalVolume; } -void S3M::Properties::setMasterVolume(unsigned char masterVolume) -{ +void S3M::Properties::setMasterVolume(unsigned char masterVolume) { d->masterVolume = masterVolume; } -void S3M::Properties::setTempo(unsigned char tempo) -{ +void S3M::Properties::setTempo(unsigned char tempo) { d->tempo = tempo; } -void S3M::Properties::setBpmSpeed(unsigned char bpmSpeed) -{ +void S3M::Properties::setBpmSpeed(unsigned char bpmSpeed) { d->bpmSpeed = bpmSpeed; } diff --git a/3rdparty/taglib/s3m/s3mproperties.h b/3rdparty/taglib/s3m/s3mproperties.h index d4b8154f3..23ce91ab3 100644 --- a/3rdparty/taglib/s3m/s3mproperties.h +++ b/3rdparty/taglib/s3m/s3mproperties.h @@ -31,66 +31,67 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace S3M { - class TAGLIB_EXPORT Properties : public AudioProperties { - friend class File; - public: - /*! Flag bits. */ - enum { - ST2Vibrato = 1, - ST2Tempo = 2, - AmigaSlides = 4, - Vol0MixOptimizations = 8, - AmigaLimits = 16, - EnableFilter = 32, - CustomData = 128 - }; +namespace S3M { +class TAGLIB_EXPORT Properties : public AudioProperties { + friend class File; - Properties(AudioProperties::ReadStyle propertiesStyle); - virtual ~Properties(); + public: + /*! Flag bits. */ + enum { + ST2Vibrato = 1, + ST2Tempo = 2, + AmigaSlides = 4, + Vol0MixOptimizations = 8, + AmigaLimits = 16, + EnableFilter = 32, + CustomData = 128 + }; - int length() const; - int lengthInSeconds() const; - int lengthInMilliseconds() const; - int bitrate() const; - int sampleRate() const; - int channels() const; + Properties(AudioProperties::ReadStyle propertiesStyle); + virtual ~Properties(); - unsigned short lengthInPatterns() const; - bool stereo() const; - unsigned short sampleCount() const; - unsigned short patternCount() const; - unsigned short flags() const; - unsigned short trackerVersion() const; - unsigned short fileFormatVersion() const; - unsigned char globalVolume() const; - unsigned char masterVolume() const; - unsigned char tempo() const; - unsigned char bpmSpeed() const; + int length() const; + int lengthInSeconds() const; + int lengthInMilliseconds() const; + int bitrate() const; + int sampleRate() const; + int channels() const; - void setChannels(int channels); + unsigned short lengthInPatterns() const; + bool stereo() const; + unsigned short sampleCount() const; + unsigned short patternCount() const; + unsigned short flags() const; + unsigned short trackerVersion() const; + unsigned short fileFormatVersion() const; + unsigned char globalVolume() const; + unsigned char masterVolume() const; + unsigned char tempo() const; + unsigned char bpmSpeed() const; - void setLengthInPatterns (unsigned short lengthInPatterns); - void setStereo (bool stereo); - void setSampleCount (unsigned short sampleCount); - void setPatternCount (unsigned short patternCount); - void setFlags (unsigned short flags); - void setTrackerVersion (unsigned short trackerVersion); - void setFileFormatVersion(unsigned short fileFormatVersion); - void setGlobalVolume (unsigned char globalVolume); - void setMasterVolume (unsigned char masterVolume); - void setTempo (unsigned char tempo); - void setBpmSpeed (unsigned char bpmSpeed); + void setChannels(int channels); - private: - Properties(const Properties&); - Properties &operator=(const Properties&); + void setLengthInPatterns(unsigned short lengthInPatterns); + void setStereo(bool stereo); + void setSampleCount(unsigned short sampleCount); + void setPatternCount(unsigned short patternCount); + void setFlags(unsigned short flags); + void setTrackerVersion(unsigned short trackerVersion); + void setFileFormatVersion(unsigned short fileFormatVersion); + void setGlobalVolume(unsigned char globalVolume); + void setMasterVolume(unsigned char masterVolume); + void setTempo(unsigned char tempo); + void setBpmSpeed(unsigned char bpmSpeed); - class PropertiesPrivate; - PropertiesPrivate *d; - }; - } -} -} + private: + Properties(const Properties &); + Properties &operator=(const Properties &); + + class PropertiesPrivate; + PropertiesPrivate *d; +}; +} // namespace S3M +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/tag.cpp b/3rdparty/taglib/tag.cpp index d88205c9a..6da9709fc 100644 --- a/3rdparty/taglib/tag.cpp +++ b/3rdparty/taglib/tag.cpp @@ -29,35 +29,26 @@ using namespace Strawberry_TagLib::TagLib; -class Tag::TagPrivate -{ - +class Tag::TagPrivate { }; -Tag::Tag() : -d(nullptr) -{ - +Tag::Tag() : d(nullptr) { } -Tag::~Tag() -{ - +Tag::~Tag() { } -bool Tag::isEmpty() const -{ +bool Tag::isEmpty() const { return (title().isEmpty() && - artist().isEmpty() && - album().isEmpty() && - comment().isEmpty() && - genre().isEmpty() && - year() == 0 && - track() == 0); + artist().isEmpty() && + album().isEmpty() && + comment().isEmpty() && + genre().isEmpty() && + year() == 0 && + track() == 0); } -PropertyMap Tag::properties() const -{ +PropertyMap Tag::properties() const { PropertyMap map; if (!(title().isEmpty())) map["TITLE"].append(title()); @@ -76,12 +67,10 @@ PropertyMap Tag::properties() const return map; } -void Tag::removeUnsupportedProperties(const StringList&) -{ +void Tag::removeUnsupportedProperties(const StringList &) { } -PropertyMap Tag::setProperties(const PropertyMap &origProps) -{ +PropertyMap Tag::setProperties(const PropertyMap &origProps) { PropertyMap properties(origProps); properties.removeEmpty(); StringList oneValueSet; @@ -89,31 +78,36 @@ PropertyMap Tag::setProperties(const PropertyMap &origProps) if (properties.contains("TITLE")) { setTitle(properties["TITLE"].front()); oneValueSet.append("TITLE"); - } else + } + else setTitle(String()); if (properties.contains("ARTIST")) { setArtist(properties["ARTIST"].front()); oneValueSet.append("ARTIST"); - } else + } + else setArtist(String()); if (properties.contains("ALBUM")) { setAlbum(properties["ALBUM"].front()); oneValueSet.append("ALBUM"); - } else + } + else setAlbum(String()); if (properties.contains("COMMENT")) { setComment(properties["COMMENT"].front()); oneValueSet.append("COMMENT"); - } else + } + else setComment(String()); if (properties.contains("GENRE")) { setGenre(properties["GENRE"].front()); oneValueSet.append("GENRE"); - } else + } + else setGenre(String()); if (properties.contains("DATE")) { @@ -122,7 +116,8 @@ PropertyMap Tag::setProperties(const PropertyMap &origProps) if (ok) { setYear(date); oneValueSet.append("DATE"); - } else + } + else setYear(0); } else @@ -134,7 +129,8 @@ PropertyMap Tag::setProperties(const PropertyMap &origProps) if (ok) { setTrack(track); oneValueSet.append("TRACKNUMBER"); - } else + } + else setTrack(0); } else @@ -142,16 +138,16 @@ PropertyMap Tag::setProperties(const PropertyMap &origProps) // for each tag that has been set above, remove the first entry in the corresponding // value list. The others will be returned as unsupported by this format. - for(StringList::ConstIterator it = oneValueSet.begin(); it != oneValueSet.end(); ++it) { + for (StringList::ConstIterator it = oneValueSet.begin(); it != oneValueSet.end(); ++it) { if (properties[*it].size() == 1) properties.erase(*it); else - properties[*it].erase( properties[*it].begin() ); + properties[*it].erase(properties[*it].begin()); } return properties; } -void Tag::duplicate(const Tag *source, Tag *target, bool overwrite) // static +void Tag::duplicate(const Tag *source, Tag *target, bool overwrite) // static { if (overwrite) { target->setTitle(source->title()); diff --git a/3rdparty/taglib/tag.h b/3rdparty/taglib/tag.h index ef6e8a8c5..d19775b2f 100644 --- a/3rdparty/taglib/tag.h +++ b/3rdparty/taglib/tag.h @@ -32,9 +32,9 @@ namespace Strawberry_TagLib { namespace TagLib { - //! A simple, generic interface to common audio meta data fields +//! A simple, generic interface to common audio meta data fields - /*! +/*! * This is an attempt to abstract away the difference in the meta data formats * of various audio codecs and tagging schemes. As such it is generally a * subset of what is available in the specific formats but should be suitable @@ -42,26 +42,24 @@ namespace TagLib { * in TagLib::AudioProperties, TagLib::File and TagLib::FileRef. */ - class PropertyMap; +class PropertyMap; - class TAGLIB_EXPORT Tag - { - public: - - /*! +class TAGLIB_EXPORT Tag { + public: + /*! * Destroys this Tag instance. */ - virtual ~Tag(); + virtual ~Tag(); - /*! + /*! * Exports the tags of the file as dictionary mapping (human readable) tag * names (Strings) to StringLists of tag values. * The default implementation in this class considers only the usual built-in * tags (artist, album, ...) and only one value per key. */ - PropertyMap properties() const; + PropertyMap properties() const; - /*! + /*! * Removes unsupported properties, or a subset of them, from the tag. * The parameter \a properties must contain only entries from * properties().unsupportedData(). @@ -69,108 +67,108 @@ namespace TagLib { * standard implementation of TagLib::Tag does nothing, since there are * no unsupported elements. */ - void removeUnsupportedProperties(const StringList& properties); + void removeUnsupportedProperties(const StringList &properties); - /*! + /*! * Sets the tags of this File to those specified in \a properties. This default * implementation sets only the tags for which setter methods exist in this class * (artist, album, ...), and only one value per key; the rest will be contained * in the returned PropertyMap. */ - PropertyMap setProperties(const PropertyMap &properties); + PropertyMap setProperties(const PropertyMap &properties); - /*! + /*! * Returns the track name; if no track name is present in the tag * String::null will be returned. */ - virtual String title() const = 0; + virtual String title() const = 0; - /*! + /*! * Returns the artist name; if no artist name is present in the tag * String::null will be returned. */ - virtual String artist() const = 0; + virtual String artist() const = 0; - /*! + /*! * Returns the album name; if no album name is present in the tag * String::null will be returned. */ - virtual String album() const = 0; + virtual String album() const = 0; - /*! + /*! * Returns the track comment; if no comment is present in the tag * String::null will be returned. */ - virtual String comment() const = 0; + virtual String comment() const = 0; - /*! + /*! * Returns the genre name; if no genre is present in the tag String::null * will be returned. */ - virtual String genre() const = 0; + virtual String genre() const = 0; - /*! + /*! * Returns the year; if there is no year set, this will return 0. */ - virtual unsigned int year() const = 0; + virtual unsigned int year() const = 0; - /*! + /*! * Returns the track number; if there is no track number set, this will * return 0. */ - virtual unsigned int track() const = 0; + virtual unsigned int track() const = 0; - /*! + /*! * Sets the title to \a s. If \a s is String::null then this value will be * cleared. */ - virtual void setTitle(const String &s) = 0; + virtual void setTitle(const String &s) = 0; - /*! + /*! * Sets the artist to \a s. If \a s is String::null then this value will be * cleared. */ - virtual void setArtist(const String &s) = 0; + virtual void setArtist(const String &s) = 0; - /*! + /*! * Sets the album to \a s. If \a s is String::null then this value will be * cleared. */ - virtual void setAlbum(const String &s) = 0; + virtual void setAlbum(const String &s) = 0; - /*! + /*! * Sets the comment to \a s. If \a s is String::null then this value will be * cleared. */ - virtual void setComment(const String &s) = 0; + virtual void setComment(const String &s) = 0; - /*! + /*! * Sets the genre to \a s. If \a s is String::null then this value will be * cleared. For tag formats that use a fixed set of genres, the appropriate * value will be selected based on a string comparison. A list of available * genres for those formats should be available in that type's * implementation. */ - virtual void setGenre(const String &s) = 0; + virtual void setGenre(const String &s) = 0; - /*! + /*! * Sets the year to \a i. If \a s is 0 then this value will be cleared. */ - virtual void setYear(unsigned int i) = 0; + virtual void setYear(unsigned int i) = 0; - /*! + /*! * Sets the track to \a i. If \a s is 0 then this value will be cleared. */ - virtual void setTrack(unsigned int i) = 0; + virtual void setTrack(unsigned int i) = 0; - /*! + /*! * Returns true if the tag does not contain any data. This should be * reimplemented in subclasses that provide more than the basic tagging * abilities in this class. */ - virtual bool isEmpty() const; + virtual bool isEmpty() const; - /*! + /*! * Copies the generic data from one tag to another. * * \note This will no affect any of the lower level details of the tag. For @@ -181,23 +179,23 @@ namespace TagLib { * If \a overwrite is true then the values will be unconditionally copied. * If false only empty values will be overwritten. */ - static void duplicate(const Tag *source, Tag *target, bool overwrite = true); + static void duplicate(const Tag *source, Tag *target, bool overwrite = true); - protected: - /*! + protected: + /*! * Construct a Tag. This is protected since tags should only be instantiated * through subclasses. */ - Tag(); + Tag(); - private: - Tag(const Tag &); - Tag &operator=(const Tag &); + private: + Tag(const Tag &); + Tag &operator=(const Tag &); - class TagPrivate; - TagPrivate *d; - }; -} -} + class TagPrivate; + TagPrivate *d; +}; +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/taglib_export.h b/3rdparty/taglib/taglib_export.h index 737ae6442..90e20f0ea 100644 --- a/3rdparty/taglib/taglib_export.h +++ b/3rdparty/taglib/taglib_export.h @@ -27,17 +27,17 @@ #define TAGLIB_EXPORT_H #if defined(TAGLIB_STATIC) -#define TAGLIB_EXPORT +# define TAGLIB_EXPORT #elif (defined(_WIN32) || defined(_WIN64)) -#ifdef MAKE_TAGLIB_LIB -#define TAGLIB_EXPORT __declspec(dllexport) -#else -#define TAGLIB_EXPORT __declspec(dllimport) -#endif +# ifdef MAKE_TAGLIB_LIB +# define TAGLIB_EXPORT __declspec(dllexport) +# else +# define TAGLIB_EXPORT __declspec(dllimport) +# endif #elif defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 1) -#define TAGLIB_EXPORT __attribute__ ((visibility("default"))) +# define TAGLIB_EXPORT __attribute__((visibility("default"))) #else -#define TAGLIB_EXPORT +# define TAGLIB_EXPORT #endif #endif diff --git a/3rdparty/taglib/tagunion.cpp b/3rdparty/taglib/tagunion.cpp index d7f16697b..995476f52 100644 --- a/3rdparty/taglib/tagunion.cpp +++ b/3rdparty/taglib/tagunion.cpp @@ -35,42 +35,38 @@ using namespace Strawberry_TagLib::TagLib; -#define stringUnion(method) \ - if(tag(0) && !tag(0)->method().isEmpty()) \ - return tag(0)->method(); \ - if(tag(1) && !tag(1)->method().isEmpty()) \ - return tag(1)->method(); \ - if(tag(2) && !tag(2)->method().isEmpty()) \ - return tag(2)->method(); \ - return String(); \ +#define stringUnion(method) \ + if (tag(0) && !tag(0)->method().isEmpty()) \ + return tag(0)->method(); \ + if (tag(1) && !tag(1)->method().isEmpty()) \ + return tag(1)->method(); \ + if (tag(2) && !tag(2)->method().isEmpty()) \ + return tag(2)->method(); \ + return String(); -#define numberUnion(method) \ - if(tag(0) && tag(0)->method() > 0) \ - return tag(0)->method(); \ - if(tag(1) && tag(1)->method() > 0) \ - return tag(1)->method(); \ - if(tag(2) && tag(2)->method() > 0) \ - return tag(2)->method(); \ +#define numberUnion(method) \ + if (tag(0) && tag(0)->method() > 0) \ + return tag(0)->method(); \ + if (tag(1) && tag(1)->method() > 0) \ + return tag(1)->method(); \ + if (tag(2) && tag(2)->method() > 0) \ + return tag(2)->method(); \ return 0 -#define setUnion(method, value) \ - if(tag(0)) \ - tag(0)->set##method(value); \ - if(tag(1)) \ - tag(1)->set##method(value); \ - if(tag(2)) \ - tag(2)->set##method(value); \ - -class TagUnion::TagUnionPrivate -{ -public: - TagUnionPrivate() : tags(3, static_cast(0)) - { +#define setUnion(method, value) \ + if (tag(0)) \ + tag(0)->set##method(value); \ + if (tag(1)) \ + tag(1)->set##method(value); \ + if (tag(2)) \ + tag(2)->set##method(value); +class TagUnion::TagUnionPrivate { + public: + TagUnionPrivate() : tags(3, static_cast(0)) { } - ~TagUnionPrivate() - { + ~TagUnionPrivate() { delete tags[0]; delete tags[1]; delete tags[2]; @@ -79,57 +75,50 @@ public: std::vector tags; }; -TagUnion::TagUnion(Tag *first, Tag *second, Tag *third) : - d(new TagUnionPrivate()) -{ +TagUnion::TagUnion(Tag *first, Tag *second, Tag *third) : d(new TagUnionPrivate()) { d->tags[0] = first; d->tags[1] = second; d->tags[2] = third; } -TagUnion::~TagUnion() -{ +TagUnion::~TagUnion() { delete d; } -Tag *TagUnion::operator[](int index) const -{ +Tag *TagUnion::operator[](int index) const { return tag(index); } -Tag *TagUnion::tag(int index) const -{ +Tag *TagUnion::tag(int index) const { return d->tags[index]; } -void TagUnion::set(int index, Tag *tag) -{ +void TagUnion::set(int index, Tag *tag) { delete d->tags[index]; d->tags[index] = tag; } -PropertyMap TagUnion::properties() const -{ +PropertyMap TagUnion::properties() const { // This is an ugly workaround but we can't add a virtual function. // Should be virtual in taglib2. - for(size_t i = 0; i < 3; ++i) { + for (size_t i = 0; i < 3; ++i) { - if(d->tags[i] && !d->tags[i]->isEmpty()) { + if (d->tags[i] && !d->tags[i]->isEmpty()) { - if(dynamic_cast(d->tags[i])) + if (dynamic_cast(d->tags[i])) return dynamic_cast(d->tags[i])->properties(); - else if(dynamic_cast(d->tags[i])) + else if (dynamic_cast(d->tags[i])) return dynamic_cast(d->tags[i])->properties(); - else if(dynamic_cast(d->tags[i])) + else if (dynamic_cast(d->tags[i])) return dynamic_cast(d->tags[i])->properties(); - else if(dynamic_cast(d->tags[i])) + else if (dynamic_cast(d->tags[i])) return dynamic_cast(d->tags[i])->properties(); - else if(dynamic_cast(d->tags[i])) + else if (dynamic_cast(d->tags[i])) return dynamic_cast(d->tags[i])->properties(); } } @@ -137,112 +126,95 @@ PropertyMap TagUnion::properties() const return PropertyMap(); } -void TagUnion::removeUnsupportedProperties(const StringList &unsupported) -{ +void TagUnion::removeUnsupportedProperties(const StringList &unsupported) { // This is an ugly workaround but we can't add a virtual function. // Should be virtual in taglib2. - for(size_t i = 0; i < 3; ++i) { + for (size_t i = 0; i < 3; ++i) { - if(d->tags[i]) { + if (d->tags[i]) { - if(dynamic_cast(d->tags[i])) + if (dynamic_cast(d->tags[i])) dynamic_cast(d->tags[i])->removeUnsupportedProperties(unsupported); - else if(dynamic_cast(d->tags[i])) + else if (dynamic_cast(d->tags[i])) dynamic_cast(d->tags[i])->removeUnsupportedProperties(unsupported); - else if(dynamic_cast(d->tags[i])) + else if (dynamic_cast(d->tags[i])) dynamic_cast(d->tags[i])->removeUnsupportedProperties(unsupported); - else if(dynamic_cast(d->tags[i])) + else if (dynamic_cast(d->tags[i])) dynamic_cast(d->tags[i])->removeUnsupportedProperties(unsupported); - else if(dynamic_cast(d->tags[i])) + else if (dynamic_cast(d->tags[i])) dynamic_cast(d->tags[i])->removeUnsupportedProperties(unsupported); } } } -String TagUnion::title() const -{ +String TagUnion::title() const { stringUnion(title); } -String TagUnion::artist() const -{ +String TagUnion::artist() const { stringUnion(artist); } -String TagUnion::album() const -{ +String TagUnion::album() const { stringUnion(album); } -String TagUnion::comment() const -{ +String TagUnion::comment() const { stringUnion(comment); } -String TagUnion::genre() const -{ +String TagUnion::genre() const { stringUnion(genre); } -unsigned int TagUnion::year() const -{ +unsigned int TagUnion::year() const { numberUnion(year); } -unsigned int TagUnion::track() const -{ +unsigned int TagUnion::track() const { numberUnion(track); } -void TagUnion::setTitle(const String &s) -{ +void TagUnion::setTitle(const String &s) { setUnion(Title, s); } -void TagUnion::setArtist(const String &s) -{ +void TagUnion::setArtist(const String &s) { setUnion(Artist, s); } -void TagUnion::setAlbum(const String &s) -{ +void TagUnion::setAlbum(const String &s) { setUnion(Album, s); } -void TagUnion::setComment(const String &s) -{ +void TagUnion::setComment(const String &s) { setUnion(Comment, s); } -void TagUnion::setGenre(const String &s) -{ +void TagUnion::setGenre(const String &s) { setUnion(Genre, s); } -void TagUnion::setYear(unsigned int i) -{ +void TagUnion::setYear(unsigned int i) { setUnion(Year, i); } -void TagUnion::setTrack(unsigned int i) -{ +void TagUnion::setTrack(unsigned int i) { setUnion(Track, i); } -bool TagUnion::isEmpty() const -{ - if(d->tags[0] && !d->tags[0]->isEmpty()) +bool TagUnion::isEmpty() const { + if (d->tags[0] && !d->tags[0]->isEmpty()) return false; - if(d->tags[1] && !d->tags[1]->isEmpty()) + if (d->tags[1] && !d->tags[1]->isEmpty()) return false; - if(d->tags[2] && !d->tags[2]->isEmpty()) + if (d->tags[2] && !d->tags[2]->isEmpty()) return false; return true; } - diff --git a/3rdparty/taglib/tagunion.h b/3rdparty/taglib/tagunion.h index f263ae08e..f54f38c9f 100644 --- a/3rdparty/taglib/tagunion.h +++ b/3rdparty/taglib/tagunion.h @@ -33,68 +33,66 @@ namespace Strawberry_TagLib { namespace TagLib { - /*! +/*! * \internal */ - class TagUnion : public Tag - { - public: +class TagUnion : public Tag { + public: + enum AccessType { Read, + Write }; - enum AccessType { Read, Write }; - - /*! + /*! * Creates a TagLib::Tag that is the union of \a first, \a second, and * \a third. The TagUnion takes ownership of these tags and will handle * their deletion. */ - TagUnion(Tag *first = 0, Tag *second = 0, Tag *third = 0); + TagUnion(Tag *first = 0, Tag *second = 0, Tag *third = 0); - virtual ~TagUnion(); + virtual ~TagUnion(); - Tag *operator[](int index) const; - Tag *tag(int index) const; + Tag *operator[](int index) const; + Tag *tag(int index) const; - void set(int index, Tag *tag); + void set(int index, Tag *tag); - PropertyMap properties() const; - void removeUnsupportedProperties(const StringList &unsupported); + PropertyMap properties() const; + void removeUnsupportedProperties(const StringList &unsupported); - virtual String title() const; - virtual String artist() const; - virtual String album() const; - virtual String comment() const; - virtual String genre() const; - virtual unsigned int year() const; - virtual unsigned int track() const; + virtual String title() const; + virtual String artist() const; + virtual String album() const; + virtual String comment() const; + virtual String genre() const; + virtual unsigned int year() const; + virtual unsigned int track() const; - virtual void setTitle(const String &s); - virtual void setArtist(const String &s); - virtual void setAlbum(const String &s); - virtual void setComment(const String &s); - virtual void setGenre(const String &s); - virtual void setYear(unsigned int i); - virtual void setTrack(unsigned int i); - virtual bool isEmpty() const; + virtual void setTitle(const String &s); + virtual void setArtist(const String &s); + virtual void setAlbum(const String &s); + virtual void setComment(const String &s); + virtual void setGenre(const String &s); + virtual void setYear(unsigned int i); + virtual void setTrack(unsigned int i); + virtual bool isEmpty() const; - template T *access(int index, bool create) - { - if(!create || tag(index)) - return static_cast(tag(index)); - - set(index, new T); + template T *access(int index, bool create) { + if (!create || tag(index)) return static_cast(tag(index)); - } - private: - TagUnion(const Tag &); - TagUnion &operator=(const Tag &); + set(index, new T); + return static_cast(tag(index)); + } - class TagUnionPrivate; - TagUnionPrivate *d; - }; -} -} + private: + TagUnion(const Tag &); + TagUnion &operator=(const Tag &); + + class TagUnionPrivate; + TagUnionPrivate *d; +}; +} // namespace TagLib +} // namespace Strawberry_TagLib #endif #endif diff --git a/3rdparty/taglib/tagutils.cpp b/3rdparty/taglib/tagutils.cpp index 2da9a75ee..1e2a8bb11 100644 --- a/3rdparty/taglib/tagutils.cpp +++ b/3rdparty/taglib/tagutils.cpp @@ -33,64 +33,60 @@ using namespace Strawberry_TagLib::TagLib; -long Utils::findID3v1(File *file) -{ - if(!file->isValid()) +long Utils::findID3v1(File *file) { + if (!file->isValid()) return -1; file->seek(-128, File::End); const long p = file->tell(); - if(file->readBlock(3) == ID3v1::Tag::fileIdentifier()) + if (file->readBlock(3) == ID3v1::Tag::fileIdentifier()) return p; return -1; } -long Utils::findID3v2(File *file) -{ - if(!file->isValid()) +long Utils::findID3v2(File *file) { + if (!file->isValid()) return -1; file->seek(0); - if(file->readBlock(3) == ID3v2::Header::fileIdentifier()) + if (file->readBlock(3) == ID3v2::Header::fileIdentifier()) return 0; return -1; } -long Utils::findAPE(File *file, long id3v1Location) -{ - if(!file->isValid()) +long Utils::findAPE(File *file, long id3v1Location) { + if (!file->isValid()) return -1; - if(id3v1Location >= 0) + if (id3v1Location >= 0) file->seek(id3v1Location - 32, File::Beginning); else file->seek(-32, File::End); const long p = file->tell(); - if(file->readBlock(8) == APE::Tag::fileIdentifier()) + if (file->readBlock(8) == APE::Tag::fileIdentifier()) return p; return -1; } ByteVector Strawberry_TagLib::TagLib::Utils::readHeader(IOStream *stream, unsigned int length, - bool skipID3v2, long *headerOffset) -{ - if(!stream || !stream->isOpen()) + bool skipID3v2, long *headerOffset) { + if (!stream || !stream->isOpen()) return ByteVector(); const long originalPosition = stream->tell(); long bufferOffset = 0; - if(skipID3v2) { + if (skipID3v2) { stream->seek(0); const ByteVector data = stream->readBlock(ID3v2::Header::size()); - if(data.startsWith(ID3v2::Header::fileIdentifier())) + if (data.startsWith(ID3v2::Header::fileIdentifier())) bufferOffset = ID3v2::Header(data).completeTagSize(); } @@ -98,7 +94,7 @@ ByteVector Strawberry_TagLib::TagLib::Utils::readHeader(IOStream *stream, unsign const ByteVector header = stream->readBlock(length); stream->seek(originalPosition); - if(headerOffset) + if (headerOffset) *headerOffset = bufferOffset; return header; diff --git a/3rdparty/taglib/tagutils.h b/3rdparty/taglib/tagutils.h index e43a2fd60..3b4f52928 100644 --- a/3rdparty/taglib/tagutils.h +++ b/3rdparty/taglib/tagutils.h @@ -30,27 +30,27 @@ #ifndef DO_NOT_DOCUMENT // tell Doxygen not to document this header -#include +# include namespace Strawberry_TagLib { namespace TagLib { - class File; - class IOStream; +class File; +class IOStream; - namespace Utils { +namespace Utils { - long findID3v1(File *file); +long findID3v1(File *file); - long findID3v2(File *file); +long findID3v2(File *file); - long findAPE(File *file, long id3v1Location); +long findAPE(File *file, long id3v1Location); - ByteVector readHeader(IOStream *stream, unsigned int length, bool skipID3v2, - long *headerOffset = 0); - } -} -} +ByteVector readHeader(IOStream *stream, unsigned int length, bool skipID3v2, + long *headerOffset = 0); +} // namespace Utils +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/toolkit/taglib.h b/3rdparty/taglib/toolkit/taglib.h index 9380e19e6..3f70fd1ea 100644 --- a/3rdparty/taglib/toolkit/taglib.h +++ b/3rdparty/taglib/toolkit/taglib.h @@ -33,25 +33,25 @@ #define TAGLIB_PATCH_VERSION 1 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 1)) || defined(__clang__) -#define TAGLIB_IGNORE_MISSING_DESTRUCTOR _Pragma("GCC diagnostic ignored \"-Wnon-virtual-dtor\"") +# define TAGLIB_IGNORE_MISSING_DESTRUCTOR _Pragma("GCC diagnostic ignored \"-Wnon-virtual-dtor\"") #else -#define TAGLIB_IGNORE_MISSING_DESTRUCTOR +# define TAGLIB_IGNORE_MISSING_DESTRUCTOR #endif #if (defined(_MSC_VER) && _MSC_VER >= 1600) -#define TAGLIB_CONSTRUCT_BITSET(x) static_cast(x) +# define TAGLIB_CONSTRUCT_BITSET(x) static_cast(x) #else -#define TAGLIB_CONSTRUCT_BITSET(x) static_cast(x) +# define TAGLIB_CONSTRUCT_BITSET(x) static_cast(x) #endif #if __cplusplus >= 201402 -#define TAGLIB_DEPRECATED [[deprecated]] +# define TAGLIB_DEPRECATED [[deprecated]] #elif defined(__GNUC__) || defined(__clang__) -#define TAGLIB_DEPRECATED __attribute__((deprecated)) +# define TAGLIB_DEPRECATED __attribute__((deprecated)) #elif defined(_MSC_VER) -#define TAGLIB_DEPRECATED __declspec(deprecated) +# define TAGLIB_DEPRECATED __declspec(deprecated) #else -#define TAGLIB_DEPRECATED +# define TAGLIB_DEPRECATED #endif #include @@ -69,24 +69,24 @@ namespace Strawberry_TagLib { namespace TagLib { - class String; +class String; - // These integer types are deprecated. Do not use them. +// These integer types are deprecated. Do not use them. - typedef wchar_t wchar; // Assumed to be sufficient to store a UTF-16 char. - typedef unsigned char uchar; - typedef unsigned short ushort; - typedef unsigned int uint; - typedef unsigned long ulong; - typedef unsigned long long ulonglong; +typedef wchar_t wchar; // Assumed to be sufficient to store a UTF-16 char. +typedef unsigned char uchar; +typedef unsigned short ushort; +typedef unsigned int uint; +typedef unsigned long ulong; +typedef unsigned long long ulonglong; - /*! +/*! * Unfortunately std::wstring isn't defined on some systems, (i.e. GCC < 3) * so I'm providing something here that should be constant. */ - typedef std::basic_string wstring; -} -} +typedef std::basic_string wstring; +} // namespace TagLib +} // namespace Strawberry_TagLib /*! * \mainpage TagLib diff --git a/3rdparty/taglib/toolkit/tbytevector.cpp b/3rdparty/taglib/toolkit/tbytevector.cpp index 79bf85f29..57e79fb6f 100644 --- a/3rdparty/taglib/toolkit/tbytevector.cpp +++ b/3rdparty/taglib/toolkit/tbytevector.cpp @@ -47,47 +47,45 @@ namespace Strawberry_TagLib { namespace TagLib { -template +template int findChar( const TIterator dataBegin, const TIterator dataEnd, - char c, unsigned int offset, int byteAlign) -{ + char c, unsigned int offset, int byteAlign) { const size_t dataSize = dataEnd - dataBegin; - if(offset + 1 > dataSize) + if (offset + 1 > dataSize) return -1; // n % 0 is invalid - if(byteAlign == 0) + if (byteAlign == 0) return -1; - for(TIterator it = dataBegin + offset; it < dataEnd; it += byteAlign) { - if(*it == c) + for (TIterator it = dataBegin + offset; it < dataEnd; it += byteAlign) { + if (*it == c) return static_cast(it - dataBegin); } return -1; } -template +template int findVector( const TIterator dataBegin, const TIterator dataEnd, const TIterator patternBegin, const TIterator patternEnd, - unsigned int offset, int byteAlign) -{ - const size_t dataSize = dataEnd - dataBegin; + unsigned int offset, int byteAlign) { + const size_t dataSize = dataEnd - dataBegin; const size_t patternSize = patternEnd - patternBegin; - if(patternSize == 0 || offset + patternSize > dataSize) + if (patternSize == 0 || offset + patternSize > dataSize) return -1; // Special case that pattern contains just single char. - if(patternSize == 1) + if (patternSize == 1) return findChar(dataBegin, dataEnd, *patternBegin, offset, byteAlign); // n % 0 is invalid - if(byteAlign == 0) + if (byteAlign == 0) return -1; // We don't use sophisticated algorithms like Knuth-Morris-Pratt here. @@ -95,16 +93,16 @@ int findVector( // In the current implementation of TagLib, data and patterns are too small // for such algorithms to work effectively. - for(TIterator it = dataBegin + offset; it < dataEnd - patternSize + 1; it += byteAlign) { + for (TIterator it = dataBegin + offset; it < dataEnd - patternSize + 1; it += byteAlign) { - TIterator itData = it; + TIterator itData = it; TIterator itPattern = patternBegin; - while(*itData == *itPattern) { + while (*itData == *itPattern) { ++itData; ++itPattern; - if(itPattern == patternEnd) + if (itPattern == patternEnd) return static_cast(it - dataBegin); } } @@ -112,10 +110,9 @@ int findVector( return -1; } -template -T toNumber(const ByteVector &v, size_t offset, size_t length, bool mostSignificantByteFirst) -{ - if(offset >= v.size()) { +template +T toNumber(const ByteVector &v, size_t offset, size_t length, bool mostSignificantByteFirst) { + if (offset >= v.size()) { debug("toNumber() -- No data to convert. Returning 0."); return 0; } @@ -123,7 +120,7 @@ T toNumber(const ByteVector &v, size_t offset, size_t length, bool mostSignifica length = std::min(length, v.size() - offset); T sum = 0; - for(size_t i = 0; i < length; i++) { + for (size_t i = 0; i < length; i++) { const size_t shift = (mostSignificantByteFirst ? length - 1 - i : i) * 8; sum |= static_cast(static_cast(v[static_cast(offset + i)])) << shift; } @@ -131,78 +128,73 @@ T toNumber(const ByteVector &v, size_t offset, size_t length, bool mostSignifica return sum; } -template -T toNumber(const ByteVector &v, size_t offset, bool mostSignificantByteFirst) -{ +template +T toNumber(const ByteVector &v, size_t offset, bool mostSignificantByteFirst) { const bool isBigEndian = (Utils::systemByteOrder() == Utils::BigEndian); const bool swap = (mostSignificantByteFirst != isBigEndian); - if(offset + sizeof(T) > v.size()) + if (offset + sizeof(T) > v.size()) return toNumber(v, offset, v.size() - offset, mostSignificantByteFirst); // Uses memcpy instead of reinterpret_cast to avoid an alignment exception. T tmp; ::memcpy(&tmp, v.data() + offset, sizeof(T)); - if(swap) + if (swap) return Utils::byteSwap(tmp); else return tmp; } -template -ByteVector fromNumber(T value, bool mostSignificantByteFirst) -{ +template +ByteVector fromNumber(T value, bool mostSignificantByteFirst) { const bool isBigEndian = (Utils::systemByteOrder() == Utils::BigEndian); const bool swap = (mostSignificantByteFirst != isBigEndian); - if(swap) + if (swap) value = Utils::byteSwap(value); return ByteVector(reinterpret_cast(&value), sizeof(T)); } -template -TFloat toFloat(const ByteVector &v, size_t offset) -{ - if(offset > v.size() - sizeof(TInt)) { +template +TFloat toFloat(const ByteVector &v, size_t offset) { + if (offset > v.size() - sizeof(TInt)) { debug("toFloat() - offset is out of range. Returning 0."); return 0.0; } union { - TInt i; + TInt i; TFloat f; } tmp; ::memcpy(&tmp, v.data() + offset, sizeof(TInt)); - if(ENDIAN != Utils::systemByteOrder()) + if (ENDIAN != Utils::systemByteOrder()) tmp.i = Utils::byteSwap(tmp.i); return tmp.f; } -template -ByteVector fromFloat(TFloat value) -{ +template +ByteVector fromFloat(TFloat value) { union { - TInt i; + TInt i; TFloat f; } tmp; tmp.f = value; - if(ENDIAN != Utils::systemByteOrder()) + if (ENDIAN != Utils::systemByteOrder()) tmp.i = Utils::byteSwap(tmp.i); return ByteVector(reinterpret_cast(&tmp), sizeof(TInt)); } -template -long double toFloat80(const ByteVector &v, size_t offset) -{ +template +long double toFloat80(const ByteVector &v, size_t offset) { using std::swap; - if(offset > v.size() - 10) { + if (offset > v.size() - 10) { debug("toFloat80() - offset is out of range. Returning 0."); return 0.0; } @@ -210,7 +202,7 @@ long double toFloat80(const ByteVector &v, size_t offset) unsigned char bytes[10]; ::memcpy(bytes, v.data() + offset, 10); - if(ENDIAN == Utils::LittleEndian) { + if (ENDIAN == Utils::LittleEndian) { swap(bytes[0], bytes[9]); swap(bytes[1], bytes[8]); swap(bytes[2], bytes[7]); @@ -225,21 +217,13 @@ long double toFloat80(const ByteVector &v, size_t offset) const int exponent = ((bytes[0] & 0x7F) << 8) | bytes[1]; // 64-bit fraction. Leading 1 is explicit. - const unsigned long long fraction - = (static_cast(bytes[2]) << 56) - | (static_cast(bytes[3]) << 48) - | (static_cast(bytes[4]) << 40) - | (static_cast(bytes[5]) << 32) - | (static_cast(bytes[6]) << 24) - | (static_cast(bytes[7]) << 16) - | (static_cast(bytes[8]) << 8) - | (static_cast(bytes[9])); + const unsigned long long fraction = (static_cast(bytes[2]) << 56) | (static_cast(bytes[3]) << 48) | (static_cast(bytes[4]) << 40) | (static_cast(bytes[5]) << 32) | (static_cast(bytes[6]) << 24) | (static_cast(bytes[7]) << 16) | (static_cast(bytes[8]) << 8) | (static_cast(bytes[9])); long double val; - if(exponent == 0 && fraction == 0) + if (exponent == 0 && fraction == 0) val = 0; else { - if(exponent == 0x7FFF) { + if (exponent == 0x7FFF) { debug("toFloat80() - can't handle the infinity or NaN. Returning 0."); return 0.0; } @@ -247,48 +231,42 @@ long double toFloat80(const ByteVector &v, size_t offset) val = ::ldexp(static_cast(fraction), exponent - 16383 - 63); } - if(negative) + if (negative) return -val; else return val; } -class ByteVector::ByteVectorPrivate -{ -public: - ByteVectorPrivate(unsigned int l, char c) : - counter(new RefCounter()), - data(new std::vector(l, c)), - offset(0), - length(l) {} +class ByteVector::ByteVectorPrivate { + public: + ByteVectorPrivate(unsigned int l, char c) : counter(new RefCounter()), + data(new std::vector(l, c)), + offset(0), + length(l) {} - ByteVectorPrivate(const char *s, unsigned int l) : - counter(new RefCounter()), - data(new std::vector(s, s + l)), - offset(0), - length(l) {} + ByteVectorPrivate(const char *s, unsigned int l) : counter(new RefCounter()), + data(new std::vector(s, s + l)), + offset(0), + length(l) {} - ByteVectorPrivate(const ByteVectorPrivate &d, unsigned int o, unsigned int l) : - counter(d.counter), - data(d.data), - offset(d.offset + o), - length(l) - { + ByteVectorPrivate(const ByteVectorPrivate &d, unsigned int o, unsigned int l) : counter(d.counter), + data(d.data), + offset(d.offset + o), + length(l) { counter->ref(); } - ~ByteVectorPrivate() - { - if(counter->deref()) { + ~ByteVectorPrivate() { + if (counter->deref()) { delete counter; delete data; } } - RefCounter *counter; + RefCounter *counter; std::vector *data; - unsigned int offset; - unsigned int length; + unsigned int offset; + unsigned int length; }; //////////////////////////////////////////////////////////////////////////////// @@ -297,46 +275,38 @@ public: ByteVector ByteVector::null; -ByteVector ByteVector::fromCString(const char *s, unsigned int length) -{ - if(length == 0xffffffff) +ByteVector ByteVector::fromCString(const char *s, unsigned int length) { + if (length == 0xffffffff) return ByteVector(s, static_cast(::strlen(s))); else return ByteVector(s, length); } -ByteVector ByteVector::fromUInt(unsigned int value, bool mostSignificantByteFirst) -{ +ByteVector ByteVector::fromUInt(unsigned int value, bool mostSignificantByteFirst) { return fromNumber(value, mostSignificantByteFirst); } -ByteVector ByteVector::fromShort(short value, bool mostSignificantByteFirst) -{ +ByteVector ByteVector::fromShort(short value, bool mostSignificantByteFirst) { return fromNumber(value, mostSignificantByteFirst); } -ByteVector ByteVector::fromLongLong(long long value, bool mostSignificantByteFirst) -{ +ByteVector ByteVector::fromLongLong(long long value, bool mostSignificantByteFirst) { return fromNumber(value, mostSignificantByteFirst); } -ByteVector ByteVector::fromFloat32LE(float value) -{ +ByteVector ByteVector::fromFloat32LE(float value) { return fromFloat(value); } -ByteVector ByteVector::fromFloat32BE(float value) -{ +ByteVector ByteVector::fromFloat32BE(float value) { return fromFloat(value); } -ByteVector ByteVector::fromFloat64LE(double value) -{ +ByteVector ByteVector::fromFloat64LE(double value) { return fromFloat(value); } -ByteVector ByteVector::fromFloat64BE(double value) -{ +ByteVector ByteVector::fromFloat64BE(double value) { return fromFloat(value); } @@ -344,177 +314,146 @@ ByteVector ByteVector::fromFloat64BE(double value) // public members //////////////////////////////////////////////////////////////////////////////// -ByteVector::ByteVector() : - d(new ByteVectorPrivate(0, '\0')) -{ +ByteVector::ByteVector() : d(new ByteVectorPrivate(0, '\0')) { } -ByteVector::ByteVector(unsigned int size, char value) : - d(new ByteVectorPrivate(size, value)) -{ +ByteVector::ByteVector(unsigned int size, char value) : d(new ByteVectorPrivate(size, value)) { } -ByteVector::ByteVector(const ByteVector &v) : - d(new ByteVectorPrivate(*v.d, 0, v.d->length)) -{ +ByteVector::ByteVector(const ByteVector &v) : d(new ByteVectorPrivate(*v.d, 0, v.d->length)) { } -ByteVector::ByteVector(const ByteVector &v, unsigned int offset, unsigned int length) : - d(new ByteVectorPrivate(*v.d, offset, length)) -{ +ByteVector::ByteVector(const ByteVector &v, unsigned int offset, unsigned int length) : d(new ByteVectorPrivate(*v.d, offset, length)) { } -ByteVector::ByteVector(char c) : - d(new ByteVectorPrivate(1, c)) -{ +ByteVector::ByteVector(char c) : d(new ByteVectorPrivate(1, c)) { } -ByteVector::ByteVector(const char *data, unsigned int length) : - d(new ByteVectorPrivate(data, length)) -{ +ByteVector::ByteVector(const char *data, unsigned int length) : d(new ByteVectorPrivate(data, length)) { } -ByteVector::ByteVector(const char *data) : - d(new ByteVectorPrivate(data, static_cast(::strlen(data)))) -{ +ByteVector::ByteVector(const char *data) : d(new ByteVectorPrivate(data, static_cast(::strlen(data)))) { } -ByteVector::~ByteVector() -{ +ByteVector::~ByteVector() { delete d; } -ByteVector &ByteVector::setData(const char *s, unsigned int length) -{ +ByteVector &ByteVector::setData(const char *s, unsigned int length) { ByteVector(s, length).swap(*this); return *this; } -ByteVector &ByteVector::setData(const char *data) -{ +ByteVector &ByteVector::setData(const char *data) { ByteVector(data).swap(*this); return *this; } -char *ByteVector::data() -{ +char *ByteVector::data() { detach(); return (size() > 0) ? (&(*d->data)[d->offset]) : 0; } -const char *ByteVector::data() const -{ +const char *ByteVector::data() const { return (size() > 0) ? (&(*d->data)[d->offset]) : 0; } -ByteVector ByteVector::mid(unsigned int index, unsigned int length) const -{ - index = std::min(index, size()); +ByteVector ByteVector::mid(unsigned int index, unsigned int length) const { + index = std::min(index, size()); length = std::min(length, size() - index); return ByteVector(*this, index, length); } -char ByteVector::at(unsigned int index) const -{ +char ByteVector::at(unsigned int index) const { return (index < size()) ? (*d->data)[d->offset + index] : 0; } -int ByteVector::find(const ByteVector &pattern, unsigned int offset, int byteAlign) const -{ +int ByteVector::find(const ByteVector &pattern, unsigned int offset, int byteAlign) const { return findVector( begin(), end(), pattern.begin(), pattern.end(), offset, byteAlign); } -int ByteVector::find(char c, unsigned int offset, int byteAlign) const -{ +int ByteVector::find(char c, unsigned int offset, int byteAlign) const { return findChar(begin(), end(), c, offset, byteAlign); } -int ByteVector::rfind(const ByteVector &pattern, unsigned int offset, int byteAlign) const -{ - if(offset > 0) { +int ByteVector::rfind(const ByteVector &pattern, unsigned int offset, int byteAlign) const { + if (offset > 0) { offset = size() - offset - pattern.size(); - if(offset >= size()) + if (offset >= size()) offset = 0; } const int pos = findVector( rbegin(), rend(), pattern.rbegin(), pattern.rend(), offset, byteAlign); - if(pos == -1) + if (pos == -1) return -1; else return size() - pos - pattern.size(); } -bool ByteVector::containsAt(const ByteVector &pattern, unsigned int offset, unsigned int patternOffset, unsigned int patternLength) const -{ - if(pattern.size() < patternLength) +bool ByteVector::containsAt(const ByteVector &pattern, unsigned int offset, unsigned int patternOffset, unsigned int patternLength) const { + if (pattern.size() < patternLength) patternLength = pattern.size(); // do some sanity checking -- all of these things are needed for the search to be valid const unsigned int compareLength = patternLength - patternOffset; - if(offset + compareLength > size() || patternOffset >= pattern.size() || patternLength == 0) + if (offset + compareLength > size() || patternOffset >= pattern.size() || patternLength == 0) return false; return (::memcmp(data() + offset, pattern.data() + patternOffset, compareLength) == 0); } -bool ByteVector::startsWith(const ByteVector &pattern) const -{ +bool ByteVector::startsWith(const ByteVector &pattern) const { return containsAt(pattern, 0); } -bool ByteVector::endsWith(const ByteVector &pattern) const -{ +bool ByteVector::endsWith(const ByteVector &pattern) const { return containsAt(pattern, size() - pattern.size()); } -ByteVector &ByteVector::replace(char oldByte, char newByte) -{ +ByteVector &ByteVector::replace(char oldByte, char newByte) { detach(); - for(ByteVector::Iterator it = begin(); it != end(); ++it) { - if(*it == oldByte) + for (ByteVector::Iterator it = begin(); it != end(); ++it) { + if (*it == oldByte) *it = newByte; } return *this; } -ByteVector &ByteVector::replace(const ByteVector &pattern, const ByteVector &with) -{ - if(pattern.size() == 1 && with.size() == 1) +ByteVector &ByteVector::replace(const ByteVector &pattern, const ByteVector &with) { + if (pattern.size() == 1 && with.size() == 1) return replace(pattern[0], with[0]); // Check if there is at least one occurrence of the pattern. int offset = find(pattern, 0); - if(offset == -1) + if (offset == -1) return *this; - if(pattern.size() == with.size()) { + if (pattern.size() == with.size()) { // We think this case might be common enough to optimize it. detach(); - do - { + do { ::memcpy(data() + offset, with.data(), with.size()); offset = find(pattern, offset + pattern.size()); - } while(offset != -1); + } while (offset != -1); } else { // Loop once to calculate the result size. unsigned int dstSize = size(); - do - { + do { dstSize += with.size() - pattern.size(); offset = find(pattern, offset + pattern.size()); - } while(offset != -1); + } while (offset != -1); // Loop again to copy modified data to the new vector. @@ -522,9 +461,9 @@ ByteVector &ByteVector::replace(const ByteVector &pattern, const ByteVector &wit int dstOffset = 0; offset = 0; - while(true) { + while (true) { const int next = find(pattern, offset); - if(next == -1) { + if (next == -1) { ::memcpy(dst.data() + dstOffset, data() + offset, size() - offset); break; } @@ -544,9 +483,8 @@ ByteVector &ByteVector::replace(const ByteVector &pattern, const ByteVector &wit return *this; } -int ByteVector::endsWithPartialMatch(const ByteVector &pattern) const -{ - if(pattern.size() > size()) +int ByteVector::endsWithPartialMatch(const ByteVector &pattern) const { + if (pattern.size() > size()) return -1; const int startIndex = size() - pattern.size(); @@ -554,17 +492,16 @@ int ByteVector::endsWithPartialMatch(const ByteVector &pattern) const // try to match the last n-1 bytes from the vector (where n is the pattern // size) -- continue trying to match n-2, n-3...1 bytes - for(unsigned int i = 1; i < pattern.size(); i++) { - if(containsAt(pattern, startIndex + i, 0, pattern.size() - i)) + for (unsigned int i = 1; i < pattern.size(); i++) { + if (containsAt(pattern, startIndex + i, 0, pattern.size() - i)) return startIndex + i; } return -1; } -ByteVector &ByteVector::append(const ByteVector &v) -{ - if(v.isEmpty()) +ByteVector &ByteVector::append(const ByteVector &v) { + if (v.isEmpty()) return *this; detach(); @@ -578,26 +515,22 @@ ByteVector &ByteVector::append(const ByteVector &v) return *this; } -ByteVector &ByteVector::append(char c) -{ +ByteVector &ByteVector::append(char c) { resize(size() + 1, c); return *this; } -ByteVector &ByteVector::clear() -{ +ByteVector &ByteVector::clear() { ByteVector().swap(*this); return *this; } -unsigned int ByteVector::size() const -{ +unsigned int ByteVector::size() const { return d->length; } -ByteVector &ByteVector::resize(unsigned int size, char padding) -{ - if(size != d->length) { +ByteVector &ByteVector::resize(unsigned int size, char padding) { + if (size != d->length) { detach(); // Remove the excessive length of the internal buffer first to pad correctly. @@ -613,68 +546,57 @@ ByteVector &ByteVector::resize(unsigned int size, char padding) return *this; } -ByteVector::Iterator ByteVector::begin() -{ +ByteVector::Iterator ByteVector::begin() { detach(); return d->data->begin() + d->offset; } -ByteVector::ConstIterator ByteVector::begin() const -{ +ByteVector::ConstIterator ByteVector::begin() const { return d->data->begin() + d->offset; } -ByteVector::Iterator ByteVector::end() -{ +ByteVector::Iterator ByteVector::end() { detach(); return d->data->begin() + d->offset + d->length; } -ByteVector::ConstIterator ByteVector::end() const -{ +ByteVector::ConstIterator ByteVector::end() const { return d->data->begin() + d->offset + d->length; } -ByteVector::ReverseIterator ByteVector::rbegin() -{ +ByteVector::ReverseIterator ByteVector::rbegin() { detach(); return d->data->rbegin() + (d->data->size() - (d->offset + d->length)); } -ByteVector::ConstReverseIterator ByteVector::rbegin() const -{ +ByteVector::ConstReverseIterator ByteVector::rbegin() const { // Workaround for the Solaris Studio 12.4 compiler. // We need a const reference to the data vector so we can ensure the const version of rbegin() is called. const std::vector &v = *d->data; return v.rbegin() + (v.size() - (d->offset + d->length)); } -ByteVector::ReverseIterator ByteVector::rend() -{ +ByteVector::ReverseIterator ByteVector::rend() { detach(); return d->data->rbegin() + (d->data->size() - d->offset); } -ByteVector::ConstReverseIterator ByteVector::rend() const -{ +ByteVector::ConstReverseIterator ByteVector::rend() const { // Workaround for the Solaris Studio 12.4 compiler. // We need a const reference to the data vector so we can ensure the const version of rbegin() is called. const std::vector &v = *d->data; return v.rbegin() + (v.size() - d->offset); } -bool ByteVector::isNull() const -{ +bool ByteVector::isNull() const { return (d == null.d); } -bool ByteVector::isEmpty() const -{ +bool ByteVector::isEmpty() const { return (d->length == 0); } -unsigned int ByteVector::checksum() const -{ +unsigned int ByteVector::checksum() const { static const unsigned int crcTable[256] = { 0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, @@ -722,239 +644,209 @@ unsigned int ByteVector::checksum() const }; unsigned int sum = 0; - for(ByteVector::ConstIterator it = begin(); it != end(); ++it) + for (ByteVector::ConstIterator it = begin(); it != end(); ++it) sum = (sum << 8) ^ crcTable[((sum >> 24) & 0xff) ^ static_cast(*it)]; return sum; } -unsigned int ByteVector::toUInt(bool mostSignificantByteFirst) const -{ +unsigned int ByteVector::toUInt(bool mostSignificantByteFirst) const { return toNumber(*this, 0, mostSignificantByteFirst); } -unsigned int ByteVector::toUInt(unsigned int offset, bool mostSignificantByteFirst) const -{ +unsigned int ByteVector::toUInt(unsigned int offset, bool mostSignificantByteFirst) const { return toNumber(*this, offset, mostSignificantByteFirst); } -unsigned int ByteVector::toUInt(unsigned int offset, unsigned int length, bool mostSignificantByteFirst) const -{ +unsigned int ByteVector::toUInt(unsigned int offset, unsigned int length, bool mostSignificantByteFirst) const { return toNumber(*this, offset, length, mostSignificantByteFirst); } -short ByteVector::toShort(bool mostSignificantByteFirst) const -{ +short ByteVector::toShort(bool mostSignificantByteFirst) const { return toNumber(*this, 0, mostSignificantByteFirst); } -short ByteVector::toShort(unsigned int offset, bool mostSignificantByteFirst) const -{ +short ByteVector::toShort(unsigned int offset, bool mostSignificantByteFirst) const { return toNumber(*this, offset, mostSignificantByteFirst); } -unsigned short ByteVector::toUShort(bool mostSignificantByteFirst) const -{ +unsigned short ByteVector::toUShort(bool mostSignificantByteFirst) const { return toNumber(*this, 0, mostSignificantByteFirst); } -unsigned short ByteVector::toUShort(unsigned int offset, bool mostSignificantByteFirst) const -{ +unsigned short ByteVector::toUShort(unsigned int offset, bool mostSignificantByteFirst) const { return toNumber(*this, offset, mostSignificantByteFirst); } -long long ByteVector::toLongLong(bool mostSignificantByteFirst) const -{ +long long ByteVector::toLongLong(bool mostSignificantByteFirst) const { return toNumber(*this, 0, mostSignificantByteFirst); } -long long ByteVector::toLongLong(unsigned int offset, bool mostSignificantByteFirst) const -{ +long long ByteVector::toLongLong(unsigned int offset, bool mostSignificantByteFirst) const { return toNumber(*this, offset, mostSignificantByteFirst); } -float ByteVector::toFloat32LE(size_t offset) const -{ +float ByteVector::toFloat32LE(size_t offset) const { return toFloat(*this, offset); } -float ByteVector::toFloat32BE(size_t offset) const -{ +float ByteVector::toFloat32BE(size_t offset) const { return toFloat(*this, offset); } -double ByteVector::toFloat64LE(size_t offset) const -{ +double ByteVector::toFloat64LE(size_t offset) const { return toFloat(*this, offset); } -double ByteVector::toFloat64BE(size_t offset) const -{ +double ByteVector::toFloat64BE(size_t offset) const { return toFloat(*this, offset); } -long double ByteVector::toFloat80LE(size_t offset) const -{ +long double ByteVector::toFloat80LE(size_t offset) const { return toFloat80(*this, offset); } -long double ByteVector::toFloat80BE(size_t offset) const -{ +long double ByteVector::toFloat80BE(size_t offset) const { return toFloat80(*this, offset); } -const char &ByteVector::operator[](int index) const -{ +const char &ByteVector::operator[](int index) const { return (*d->data)[d->offset + index]; } -char &ByteVector::operator[](int index) -{ +char &ByteVector::operator[](int index) { detach(); return (*d->data)[d->offset + index]; } -bool ByteVector::operator==(const ByteVector &v) const -{ - if(size() != v.size()) +bool ByteVector::operator==(const ByteVector &v) const { + if (size() != v.size()) return false; return (::memcmp(data(), v.data(), size()) == 0); } -bool ByteVector::operator!=(const ByteVector &v) const -{ +bool ByteVector::operator!=(const ByteVector &v) const { return !(*this == v); } -bool ByteVector::operator==(const char *s) const -{ - if(size() != ::strlen(s)) +bool ByteVector::operator==(const char *s) const { + if (size() != ::strlen(s)) return false; return (::memcmp(data(), s, size()) == 0); } -bool ByteVector::operator!=(const char *s) const -{ +bool ByteVector::operator!=(const char *s) const { return !(*this == s); } -bool ByteVector::operator<(const ByteVector &v) const -{ +bool ByteVector::operator<(const ByteVector &v) const { const int result = ::memcmp(data(), v.data(), std::min(size(), v.size())); - if(result != 0) + if (result != 0) return result < 0; else return size() < v.size(); } -bool ByteVector::operator>(const ByteVector &v) const -{ +bool ByteVector::operator>(const ByteVector &v) const { return (v < *this); } -ByteVector ByteVector::operator+(const ByteVector &v) const -{ +ByteVector ByteVector::operator+(const ByteVector &v) const { ByteVector sum(*this); sum.append(v); return sum; } -ByteVector &ByteVector::operator=(const ByteVector &v) -{ +ByteVector &ByteVector::operator=(const ByteVector &v) { ByteVector(v).swap(*this); return *this; } -ByteVector &ByteVector::operator=(char c) -{ +ByteVector &ByteVector::operator=(char c) { ByteVector(c).swap(*this); return *this; } -ByteVector &ByteVector::operator=(const char *data) -{ +ByteVector &ByteVector::operator=(const char *data) { ByteVector(data).swap(*this); return *this; } -void ByteVector::swap(ByteVector &v) -{ +void ByteVector::swap(ByteVector &v) { using std::swap; swap(d, v.d); } -ByteVector ByteVector::toHex() const -{ +ByteVector ByteVector::toHex() const { static const char hexTable[17] = "0123456789abcdef"; ByteVector encoded(size() * 2); char *p = encoded.data(); - for(unsigned int i = 0; i < size(); i++) { + for (unsigned int i = 0; i < size(); i++) { unsigned char c = data()[i]; *p++ = hexTable[(c >> 4) & 0x0F]; - *p++ = hexTable[(c ) & 0x0F]; + *p++ = hexTable[(c)&0x0F]; } return encoded; } -ByteVector ByteVector::fromBase64(const ByteVector & input) -{ +ByteVector ByteVector::fromBase64(const ByteVector &input) { static const unsigned char base64[256] = { - 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, - 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, - 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x3e,0x80,0x80,0x80,0x3f, - 0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x80,0x80,0x80,0x80,0x80,0x80, - 0x80,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e, - 0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x80,0x80,0x80,0x80,0x80, - 0x80,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28, - 0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,0x30,0x31,0x32,0x33,0x80,0x80,0x80,0x80,0x80, - 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, - 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, - 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, - 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, - 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, - 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, - 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, - 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80 + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x3e, 0x80, 0x80, 0x80, 0x3f, + 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, + 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, + 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; unsigned int len = input.size(); ByteVector output(len); - const unsigned char * src = (const unsigned char*) input.data(); - unsigned char * dst = (unsigned char*) output.data(); + const unsigned char *src = (const unsigned char *)input.data(); + unsigned char *dst = (unsigned char *)output.data(); - while(4 <= len) { + while (4 <= len) { // Check invalid character - if(base64[src[0]] == 0x80) + if (base64[src[0]] == 0x80) break; // Check invalid character - if(base64[src[1]] == 0x80) + if (base64[src[1]] == 0x80) break; // Decode first byte *dst++ = ((base64[src[0]] << 2) & 0xfc) | ((base64[src[1]] >> 4) & 0x03); - if(src[2] != '=') { + if (src[2] != '=') { // Check invalid character - if(base64[src[2]] == 0x80) + if (base64[src[2]] == 0x80) break; // Decode second byte *dst++ = ((base64[src[1]] & 0x0f) << 4) | ((base64[src[2]] >> 2) & 0x0f); - if(src[3] != '=') { + if (src[3] != '=') { // Check invalid character - if(base64[src[3]] == 0x80) + if (base64[src[3]] == 0x80) break; // Decode third byte @@ -976,23 +868,22 @@ ByteVector ByteVector::fromBase64(const ByteVector & input) } // Only return output if we processed all bytes - if(len == 0) { - output.resize(static_cast(dst - (unsigned char*) output.data())); + if (len == 0) { + output.resize(static_cast(dst - (unsigned char *)output.data())); return output; } return ByteVector(); } -ByteVector ByteVector::toBase64() const -{ +ByteVector ByteVector::toBase64() const { static const char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - if(!isEmpty()) { + if (!isEmpty()) { unsigned int len = size(); - ByteVector output(4 * ((len - 1) / 3 + 1)); // note roundup + ByteVector output(4 * ((len - 1) / 3 + 1)); // note roundup - const char * src = data(); - char * dst = output.data(); - while(3 <= len) { + const char *src = data(); + char *dst = output.data(); + while (3 <= len) { *dst++ = alphabet[(src[0] >> 2) & 0x3f]; *dst++ = alphabet[((src[0] & 0x03) << 4) | ((src[1] >> 4) & 0x0f)]; *dst++ = alphabet[((src[1] & 0x0f) << 2) | ((src[2] >> 6) & 0x03)]; @@ -1000,9 +891,9 @@ ByteVector ByteVector::toBase64() const src += 3; len -= 3; } - if(len) { + if (len) { *dst++ = alphabet[(src[0] >> 2) & 0x3f]; - if(len>1) { + if (len > 1) { *dst++ = alphabet[((src[0] & 0x03) << 4) | ((src[1] >> 4) & 0x0f)]; *dst++ = alphabet[((src[1] & 0x0f) << 2)]; } @@ -1010,7 +901,7 @@ ByteVector ByteVector::toBase64() const *dst++ = alphabet[(src[0] & 0x03) << 4]; *dst++ = '='; } - *dst++ = '='; + *dst++ = '='; } return output; } @@ -1022,25 +913,23 @@ ByteVector ByteVector::toBase64() const // protected members //////////////////////////////////////////////////////////////////////////////// -void ByteVector::detach() -{ - if(d->counter->count() > 1) { - if(!isEmpty()) +void ByteVector::detach() { + if (d->counter->count() > 1) { + if (!isEmpty()) ByteVector(&d->data->front() + d->offset, d->length).swap(*this); else ByteVector().swap(*this); } } -} -} +} // namespace TagLib +} // namespace Strawberry_TagLib //////////////////////////////////////////////////////////////////////////////// // related functions //////////////////////////////////////////////////////////////////////////////// -std::ostream &operator<<(std::ostream &s, const Strawberry_TagLib::TagLib::ByteVector &v) -{ - for(unsigned int i = 0; i < v.size(); i++) +std::ostream &operator<<(std::ostream &s, const Strawberry_TagLib::TagLib::ByteVector &v) { + for (unsigned int i = 0; i < v.size(); i++) s << v[i]; return s; } diff --git a/3rdparty/taglib/toolkit/tbytevector.h b/3rdparty/taglib/toolkit/tbytevector.h index f8291419c..70eb4d2e0 100644 --- a/3rdparty/taglib/toolkit/tbytevector.h +++ b/3rdparty/taglib/toolkit/tbytevector.h @@ -35,164 +35,163 @@ namespace Strawberry_TagLib { namespace TagLib { - //! A byte vector +//! A byte vector - /*! +/*! * This class provides a byte vector with some methods that are useful for * tagging purposes. Many of the search functions are tailored to what is * useful for finding tag related patterns in a data array. */ - class TAGLIB_EXPORT ByteVector - { - public: +class TAGLIB_EXPORT ByteVector { + public: #ifndef DO_NOT_DOCUMENT - typedef std::vector::iterator Iterator; - typedef std::vector::const_iterator ConstIterator; - typedef std::vector::reverse_iterator ReverseIterator; - typedef std::vector::const_reverse_iterator ConstReverseIterator; + typedef std::vector::iterator Iterator; + typedef std::vector::const_iterator ConstIterator; + typedef std::vector::reverse_iterator ReverseIterator; + typedef std::vector::const_reverse_iterator ConstReverseIterator; #endif - /*! + /*! * Constructs an empty byte vector. */ - ByteVector(); + ByteVector(); - /*! + /*! * Construct a vector of size \a size with all values set to \a value by * default. */ - ByteVector(unsigned int size, char value = 0); + ByteVector(unsigned int size, char value = 0); - /*! + /*! * Constructs a byte vector that is a copy of \a v. */ - ByteVector(const ByteVector &v); + ByteVector(const ByteVector &v); - /*! + /*! * Constructs a byte vector that is a copy of \a v. */ - ByteVector(const ByteVector &v, unsigned int offset, unsigned int length); + ByteVector(const ByteVector &v, unsigned int offset, unsigned int length); - /*! + /*! * Constructs a byte vector that contains \a c. */ - ByteVector(char c); + ByteVector(char c); - /*! + /*! * Constructs a byte vector that copies \a data for up to \a length bytes. */ - ByteVector(const char *data, unsigned int length); + ByteVector(const char *data, unsigned int length); - /*! + /*! * Constructs a byte vector that copies \a data up to the first null * byte. This is particularly useful for constructing byte arrays from * string constants. * * \warning The behavior is undefined if \a data is not null terminated. */ - ByteVector(const char *data); + ByteVector(const char *data); - /*! + /*! * Destroys this ByteVector instance. */ - virtual ~ByteVector(); + virtual ~ByteVector(); - /*! + /*! * Sets the data for the byte array using the first \a length bytes of \a data */ - ByteVector &setData(const char *data, unsigned int length); + ByteVector &setData(const char *data, unsigned int length); - /*! + /*! * Sets the data for the byte array copies \a data up to the first null * byte. The behavior is undefined if \a data is not null terminated. */ - ByteVector &setData(const char *data); + ByteVector &setData(const char *data); - /*! + /*! * Returns a pointer to the internal data structure. * * \warning Care should be taken when modifying this data structure as it is * easy to corrupt the ByteVector when doing so. Specifically, while the * data may be changed, its length may not be. */ - char *data(); + char *data(); - /*! + /*! * Returns a pointer to the internal data structure which may not be modified. */ - const char *data() const; + const char *data() const; - /*! + /*! * Returns a byte vector made up of the bytes starting at \a index and * for \a length bytes. If \a length is not specified it will return the bytes * from \a index to the end of the vector. */ - ByteVector mid(unsigned int index, unsigned int length = 0xffffffff) const; + ByteVector mid(unsigned int index, unsigned int length = 0xffffffff) const; - /*! + /*! * This essentially performs the same as operator[](), but instead of causing * a runtime error if the index is out of bounds, it will return a null byte. */ - char at(unsigned int index) const; + char at(unsigned int index) const; - /*! + /*! * Searches the ByteVector for \a pattern starting at \a offset and returns * the offset. Returns -1 if the pattern was not found. If \a byteAlign is * specified the pattern will only be matched if it starts on a byte divisible * by \a byteAlign (starting from \a offset). */ - int find(const ByteVector &pattern, unsigned int offset = 0, int byteAlign = 1) const; + int find(const ByteVector &pattern, unsigned int offset = 0, int byteAlign = 1) const; - /*! + /*! * Searches the char for \a c starting at \a offset and returns * the offset. Returns \a -1 if the pattern was not found. If \a byteAlign is * specified the pattern will only be matched if it starts on a byte divisible * by \a byteAlign (starting from \a offset). */ - int find(char c, unsigned int offset = 0, int byteAlign = 1) const; + int find(char c, unsigned int offset = 0, int byteAlign = 1) const; - /*! + /*! * Searches the ByteVector for \a pattern starting from either the end of the * vector or \a offset and returns the offset. Returns -1 if the pattern was * not found. If \a byteAlign is specified the pattern will only be matched * if it starts on a byte divisible by \a byteAlign (starting from \a offset). */ - int rfind(const ByteVector &pattern, unsigned int offset = 0, int byteAlign = 1) const; + int rfind(const ByteVector &pattern, unsigned int offset = 0, int byteAlign = 1) const; - /*! + /*! * Checks to see if the vector contains the \a pattern starting at position * \a offset. Optionally, if you only want to search for part of the pattern * you can specify an offset within the pattern to start from. Also, you can * specify to only check for the first \a patternLength bytes of \a pattern with * the \a patternLength argument. */ - bool containsAt(const ByteVector &pattern, unsigned int offset, - unsigned int patternOffset = 0, unsigned int patternLength = 0xffffffff) const; + bool containsAt(const ByteVector &pattern, unsigned int offset, + unsigned int patternOffset = 0, unsigned int patternLength = 0xffffffff) const; - /*! + /*! * Returns true if the vector starts with \a pattern. */ - bool startsWith(const ByteVector &pattern) const; + bool startsWith(const ByteVector &pattern) const; - /*! + /*! * Returns true if the vector ends with \a pattern. */ - bool endsWith(const ByteVector &pattern) const; + bool endsWith(const ByteVector &pattern) const; - /*! + /*! * Replaces \a oldByte with \a newByte and returns a reference to the * ByteVector after the operation. This \e does modify the vector. */ - ByteVector &replace(char oldByte, char newByte); + ByteVector &replace(char oldByte, char newByte); - /*! + /*! * Replaces \a pattern with \a with and returns a reference to the ByteVector * after the operation. This \e does modify the vector. */ - ByteVector &replace(const ByteVector &pattern, const ByteVector &with); + ByteVector &replace(const ByteVector &pattern, const ByteVector &with); - /*! + /*! * Checks for a partial match of \a pattern at the end of the vector. It * returns the offset of the partial match within the vector, or -1 if the * pattern is not found. This method is particularly useful when searching for @@ -202,76 +201,76 @@ namespace TagLib { * \note This will not match the complete pattern at the end of the string; use * endsWith() for that. */ - int endsWithPartialMatch(const ByteVector &pattern) const; + int endsWithPartialMatch(const ByteVector &pattern) const; - /*! + /*! * Appends \a v to the end of the ByteVector. */ - ByteVector &append(const ByteVector &v); + ByteVector &append(const ByteVector &v); - /*! + /*! * Appends \a c to the end of the ByteVector. */ - ByteVector &append(char c); + ByteVector &append(char c); - /*! + /*! * Clears the data. */ - ByteVector &clear(); + ByteVector &clear(); - /*! + /*! * Returns the size of the array. */ - unsigned int size() const; + unsigned int size() const; - /*! + /*! * Resize the vector to \a size. If the vector is currently less than * \a size, pad the remaining spaces with \a padding. Returns a reference * to the resized vector. */ - ByteVector &resize(unsigned int size, char padding = 0); + ByteVector &resize(unsigned int size, char padding = 0); - /*! + /*! * Returns an Iterator that points to the front of the vector. */ - Iterator begin(); + Iterator begin(); - /*! + /*! * Returns a ConstIterator that points to the front of the vector. */ - ConstIterator begin() const; + ConstIterator begin() const; - /*! + /*! * Returns an Iterator that points to the back of the vector. */ - Iterator end(); + Iterator end(); - /*! + /*! * Returns a ConstIterator that points to the back of the vector. */ - ConstIterator end() const; + ConstIterator end() const; - /*! + /*! * Returns a ReverseIterator that points to the front of the vector. */ - ReverseIterator rbegin(); + ReverseIterator rbegin(); - /*! + /*! * Returns a ConstReverseIterator that points to the front of the vector. */ - ConstReverseIterator rbegin() const; + ConstReverseIterator rbegin() const; - /*! + /*! * Returns a ReverseIterator that points to the back of the vector. */ - ReverseIterator rend(); + ReverseIterator rend(); - /*! + /*! * Returns a ConstReverseIterator that points to the back of the vector. */ - ConstReverseIterator rend() const; + ConstReverseIterator rend() const; - /*! + /*! * Returns true if the vector is null. * * \note A vector may be empty without being null. So do not use this @@ -281,26 +280,26 @@ namespace TagLib { * * \deprecated */ - // BIC: remove - bool isNull() const; + // BIC: remove + bool isNull() const; - /*! + /*! * Returns true if the ByteVector is empty. * * \see size() * \see isNull() */ - bool isEmpty() const; + bool isEmpty() const; - /*! + /*! * Returns a CRC checksum of the byte vector's data. * * \note This uses an uncommon variant of CRC32 specializes in Ogg. */ - // BIC: Remove or make generic. - unsigned int checksum() const; + // BIC: Remove or make generic. + unsigned int checksum() const; - /*! + /*! * Converts the first 4 bytes of the vector to an unsigned integer. * * If \a mostSignificantByteFirst is true this will operate left to right @@ -310,9 +309,9 @@ namespace TagLib { * * \see fromUInt() */ - unsigned int toUInt(bool mostSignificantByteFirst = true) const; + unsigned int toUInt(bool mostSignificantByteFirst = true) const; - /*! + /*! * Converts the 4 bytes at \a offset of the vector to an unsigned integer. * * If \a mostSignificantByteFirst is true this will operate left to right @@ -322,9 +321,9 @@ namespace TagLib { * * \see fromUInt() */ - unsigned int toUInt(unsigned int offset, bool mostSignificantByteFirst = true) const; + unsigned int toUInt(unsigned int offset, bool mostSignificantByteFirst = true) const; - /*! + /*! * Converts the \a length bytes at \a offset of the vector to an unsigned * integer. If \a length is larger than 4, the excess is ignored. * @@ -335,10 +334,10 @@ namespace TagLib { * * \see fromUInt() */ - unsigned int toUInt(unsigned int offset, unsigned int length, - bool mostSignificantByteFirst = true) const; + unsigned int toUInt(unsigned int offset, unsigned int length, + bool mostSignificantByteFirst = true) const; - /*! + /*! * Converts the first 2 bytes of the vector to a (signed) short. * * If \a mostSignificantByteFirst is true this will operate left to right @@ -347,9 +346,9 @@ namespace TagLib { * * \see fromShort() */ - short toShort(bool mostSignificantByteFirst = true) const; + short toShort(bool mostSignificantByteFirst = true) const; - /*! + /*! * Converts the 2 bytes at \a offset of the vector to a (signed) short. * * If \a mostSignificantByteFirst is true this will operate left to right @@ -358,9 +357,9 @@ namespace TagLib { * * \see fromShort() */ - short toShort(unsigned int offset, bool mostSignificantByteFirst = true) const; + short toShort(unsigned int offset, bool mostSignificantByteFirst = true) const; - /*! + /*! * Converts the first 2 bytes of the vector to a unsigned short. * * If \a mostSignificantByteFirst is true this will operate left to right @@ -369,9 +368,9 @@ namespace TagLib { * * \see fromShort() */ - unsigned short toUShort(bool mostSignificantByteFirst = true) const; + unsigned short toUShort(bool mostSignificantByteFirst = true) const; - /*! + /*! * Converts the 2 bytes at \a offset of the vector to a unsigned short. * * If \a mostSignificantByteFirst is true this will operate left to right @@ -380,9 +379,9 @@ namespace TagLib { * * \see fromShort() */ - unsigned short toUShort(unsigned int offset, bool mostSignificantByteFirst = true) const; + unsigned short toUShort(unsigned int offset, bool mostSignificantByteFirst = true) const; - /*! + /*! * Converts the first 8 bytes of the vector to a (signed) long long. * * If \a mostSignificantByteFirst is true this will operate left to right @@ -392,9 +391,9 @@ namespace TagLib { * * \see fromUInt() */ - long long toLongLong(bool mostSignificantByteFirst = true) const; + long long toLongLong(bool mostSignificantByteFirst = true) const; - /*! + /*! * Converts the 8 bytes at \a offset of the vector to a (signed) long long. * * If \a mostSignificantByteFirst is true this will operate left to right @@ -404,49 +403,49 @@ namespace TagLib { * * \see fromUInt() */ - long long toLongLong(unsigned int offset, bool mostSignificantByteFirst = true) const; + long long toLongLong(unsigned int offset, bool mostSignificantByteFirst = true) const; - /* + /* * Converts the 4 bytes at \a offset of the vector to a float as an IEEE754 * 32-bit little-endian floating point number. */ - float toFloat32LE(size_t offset) const; + float toFloat32LE(size_t offset) const; - /* + /* * Converts the 4 bytes at \a offset of the vector to a float as an IEEE754 * 32-bit big-endian floating point number. */ - float toFloat32BE(size_t offset) const; + float toFloat32BE(size_t offset) const; - /* + /* * Converts the 8 bytes at \a offset of the vector to a double as an IEEE754 * 64-bit little-endian floating point number. */ - double toFloat64LE(size_t offset) const; + double toFloat64LE(size_t offset) const; - /* + /* * Converts the 8 bytes at \a offset of the vector to a double as an IEEE754 * 64-bit big-endian floating point number. */ - double toFloat64BE(size_t offset) const; + double toFloat64BE(size_t offset) const; - /* + /* * Converts the 10 bytes at \a offset of the vector to a long double as an * IEEE754 80-bit little-endian floating point number. * * \note This may compromise the precision depends on the size of long double. */ - long double toFloat80LE(size_t offset) const; + long double toFloat80LE(size_t offset) const; - /* + /* * Converts the 10 bytes at \a offset of the vector to a long double as an * IEEE754 80-bit big-endian floating point number. * * \note This may compromise the precision depends on the size of long double. */ - long double toFloat80BE(size_t offset) const; + long double toFloat80BE(size_t offset) const; - /*! + /*! * Creates a 4 byte ByteVector based on \a value. If * \a mostSignificantByteFirst is true, then this will operate left to right * in building the ByteVector. For example if \a mostSignificantByteFirst is @@ -455,9 +454,9 @@ namespace TagLib { * * \see toUInt() */ - static ByteVector fromUInt(unsigned int value, bool mostSignificantByteFirst = true); + static ByteVector fromUInt(unsigned int value, bool mostSignificantByteFirst = true); - /*! + /*! * Creates a 2 byte ByteVector based on \a value. If * \a mostSignificantByteFirst is true, then this will operate left to right * in building the ByteVector. For example if \a mostSignificantByteFirst is @@ -465,9 +464,9 @@ namespace TagLib { * * \see toShort() */ - static ByteVector fromShort(short value, bool mostSignificantByteFirst = true); + static ByteVector fromShort(short value, bool mostSignificantByteFirst = true); - /*! + /*! * Creates a 8 byte ByteVector based on \a value. If * \a mostSignificantByteFirst is true, then this will operate left to right * in building the ByteVector. For example if \a mostSignificantByteFirst is @@ -476,117 +475,117 @@ namespace TagLib { * * \see toLongLong() */ - static ByteVector fromLongLong(long long value, bool mostSignificantByteFirst = true); + static ByteVector fromLongLong(long long value, bool mostSignificantByteFirst = true); - /*! + /*! * Creates a 4 byte ByteVector based on \a value as an IEEE754 32-bit * little-endian floating point number. * * \see fromFloat32BE() */ - static ByteVector fromFloat32LE(float value); + static ByteVector fromFloat32LE(float value); - /*! + /*! * Creates a 4 byte ByteVector based on \a value as an IEEE754 32-bit * big-endian floating point number. * * \see fromFloat32LE() */ - static ByteVector fromFloat32BE(float value); + static ByteVector fromFloat32BE(float value); - /*! + /*! * Creates a 8 byte ByteVector based on \a value as an IEEE754 64-bit * little-endian floating point number. * * \see fromFloat64BE() */ - static ByteVector fromFloat64LE(double value); + static ByteVector fromFloat64LE(double value); - /*! + /*! * Creates a 8 byte ByteVector based on \a value as an IEEE754 64-bit * big-endian floating point number. * * \see fromFloat64LE() */ - static ByteVector fromFloat64BE(double value); + static ByteVector fromFloat64BE(double value); - /*! + /*! * Returns a ByteVector based on the CString \a s. */ - static ByteVector fromCString(const char *s, unsigned int length = 0xffffffff); + static ByteVector fromCString(const char *s, unsigned int length = 0xffffffff); - /*! + /*! * Returns a const reference to the byte at \a index. */ - const char &operator[](int index) const; + const char &operator[](int index) const; - /*! + /*! * Returns a reference to the byte at \a index. */ - char &operator[](int index); + char &operator[](int index); - /*! + /*! * Returns true if this ByteVector and \a v are equal. */ - bool operator==(const ByteVector &v) const; + bool operator==(const ByteVector &v) const; - /*! + /*! * Returns true if this ByteVector and \a v are not equal. */ - bool operator!=(const ByteVector &v) const; + bool operator!=(const ByteVector &v) const; - /*! + /*! * Returns true if this ByteVector and the null terminated C string \a s * contain the same data. */ - bool operator==(const char *s) const; + bool operator==(const char *s) const; - /*! + /*! * Returns true if this ByteVector and the null terminated C string \a s * do not contain the same data. */ - bool operator!=(const char *s) const; + bool operator!=(const char *s) const; - /*! + /*! * Returns true if this ByteVector is less than \a v. The value of the * vectors is determined by evaluating the character from left to right, and * in the event one vector is a superset of the other, the size is used. */ - bool operator<(const ByteVector &v) const; + bool operator<(const ByteVector &v) const; - /*! + /*! * Returns true if this ByteVector is greater than \a v. */ - bool operator>(const ByteVector &v) const; + bool operator>(const ByteVector &v) const; - /*! + /*! * Returns a vector that is \a v appended to this vector. */ - ByteVector operator+(const ByteVector &v) const; + ByteVector operator+(const ByteVector &v) const; - /*! + /*! * Copies ByteVector \a v. */ - ByteVector &operator=(const ByteVector &v); + ByteVector &operator=(const ByteVector &v); - /*! + /*! * Copies a byte \a c. */ - ByteVector &operator=(char c); + ByteVector &operator=(char c); - /*! + /*! * Copies \a data up to the first null byte. * * \warning The behavior is undefined if \a data is not null terminated. */ - ByteVector &operator=(const char *data); + ByteVector &operator=(const char *data); - /*! + /*! * Exchanges the content of the ByteVector by the content of \a v. */ - void swap(ByteVector &v); + void swap(ByteVector &v); - /*! + /*! * A static, empty ByteVector which is convenient and fast (since returning * an empty or "null" value does not require instantiating a new ByteVector). * @@ -595,38 +594,38 @@ namespace TagLib { * * \deprecated */ - // BIC: remove - static ByteVector null; + // BIC: remove + static ByteVector null; - /*! + /*! * Returns a hex-encoded copy of the byte vector. */ - ByteVector toHex() const; + ByteVector toHex() const; - /*! + /*! * Returns a base64 encoded copy of the byte vector */ - ByteVector toBase64() const; + ByteVector toBase64() const; - /*! + /*! * Decodes the base64 encoded byte vector. */ - static ByteVector fromBase64(const ByteVector &); + static ByteVector fromBase64(const ByteVector &); - protected: - /* + protected: + /* * If this ByteVector is being shared via implicit sharing, do a deep copy * of the data and separate from the shared members. This should be called * by all non-const subclass members. */ - void detach(); + void detach(); - private: - class ByteVectorPrivate; - ByteVectorPrivate *d; - }; -} -} + private: + class ByteVectorPrivate; + ByteVectorPrivate *d; +}; +} // namespace TagLib +} // namespace Strawberry_TagLib /*! * \relates Strawberry_TagLib::TagLib::ByteVector diff --git a/3rdparty/taglib/toolkit/tbytevectorlist.cpp b/3rdparty/taglib/toolkit/tbytevectorlist.cpp index c23b9f47e..3b9ce0381 100644 --- a/3rdparty/taglib/toolkit/tbytevectorlist.cpp +++ b/3rdparty/taglib/toolkit/tbytevectorlist.cpp @@ -27,9 +27,7 @@ using namespace Strawberry_TagLib::TagLib; -class ByteVectorListPrivate -{ - +class ByteVectorListPrivate { }; //////////////////////////////////////////////////////////////////////////////// @@ -37,22 +35,19 @@ class ByteVectorListPrivate //////////////////////////////////////////////////////////////////////////////// ByteVectorList ByteVectorList::split(const ByteVector &v, const ByteVector &pattern, - int byteAlign) -{ + int byteAlign) { return split(v, pattern, byteAlign, 0); } ByteVectorList ByteVectorList::split(const ByteVector &v, const ByteVector &pattern, - int byteAlign, int max) -{ + int byteAlign, int max) { ByteVectorList l; unsigned int previousOffset = 0; - for(int offset = v.find(pattern, 0, byteAlign); - offset != -1 && (max == 0 || max > int(l.size()) + 1); - offset = v.find(pattern, offset + pattern.size(), byteAlign)) - { - if(offset - previousOffset >= 1) + for (int offset = v.find(pattern, 0, byteAlign); + offset != -1 && (max == 0 || max > int(l.size()) + 1); + offset = v.find(pattern, offset + pattern.size(), byteAlign)) { + if (offset - previousOffset >= 1) l.append(v.mid(previousOffset, offset - previousOffset)); else l.append(ByteVector()); @@ -60,7 +55,7 @@ ByteVectorList ByteVectorList::split(const ByteVector &v, const ByteVector &patt previousOffset = offset + pattern.size(); } - if(previousOffset < v.size()) + if (previousOffset < v.size()) l.append(v.mid(previousOffset, v.size() - previousOffset)); return l; @@ -70,28 +65,22 @@ ByteVectorList ByteVectorList::split(const ByteVector &v, const ByteVector &patt // public members //////////////////////////////////////////////////////////////////////////////// -ByteVectorList::ByteVectorList() : - List(), - d(nullptr) -{ - +ByteVectorList::ByteVectorList() : List(), + d(nullptr) { } -ByteVectorList::~ByteVectorList() -{ - +ByteVectorList::~ByteVectorList() { } -ByteVector ByteVectorList::toByteVector(const ByteVector &separator) const -{ +ByteVector ByteVectorList::toByteVector(const ByteVector &separator) const { ByteVector v; ConstIterator it = begin(); - while(it != end()) { + while (it != end()) { v.append(*it); it++; - if(it != end()) + if (it != end()) v.append(separator); } diff --git a/3rdparty/taglib/toolkit/tbytevectorlist.h b/3rdparty/taglib/toolkit/tbytevectorlist.h index fd93b3796..68c1f89ce 100644 --- a/3rdparty/taglib/toolkit/tbytevectorlist.h +++ b/3rdparty/taglib/toolkit/tbytevectorlist.h @@ -33,54 +33,53 @@ namespace Strawberry_TagLib { namespace TagLib { - //! A list of ByteVectors +//! A list of ByteVectors - /*! +/*! * A List specialization with some handy features useful for ByteVectors. */ - class TAGLIB_EXPORT ByteVectorList : public List - { - public: - - /*! +class TAGLIB_EXPORT ByteVectorList : public List { + public: + /*! * Construct an empty ByteVectorList. */ - ByteVectorList(); + ByteVectorList(); - /*! + /*! * Destroys this ByteVectorList instance. */ - virtual ~ByteVectorList(); + virtual ~ByteVectorList(); - /*! + /*! * Convert the ByteVectorList to a ByteVector separated by \a separator. By * default a space is used. */ - ByteVector toByteVector(const ByteVector &separator = " ") const; + ByteVector toByteVector(const ByteVector &separator = " ") const; - /*! + /*! * Splits the ByteVector \a v into several strings at \a pattern. This will * not include the pattern in the returned ByteVectors. */ - static ByteVectorList split(const ByteVector &v, const ByteVector &pattern, - int byteAlign = 1); - /*! + static ByteVectorList split(const ByteVector &v, const ByteVector &pattern, + int byteAlign = 1); + /*! * Splits the ByteVector \a v into several strings at \a pattern. This will * not include the pattern in the returned ByteVectors. \a max is the * maximum number of entries that will be separated. If \a max for instance * is 2 then a maximum of 1 match will be found and the vector will be split * on that match. */ - // BIC: merge with the function above - static ByteVectorList split(const ByteVector &v, const ByteVector &pattern, - int byteAlign, int max); - private: - class ByteVectorListPrivate; - ByteVectorListPrivate *d; - }; + // BIC: merge with the function above + static ByteVectorList split(const ByteVector &v, const ByteVector &pattern, + int byteAlign, int max); -} -} + private: + class ByteVectorListPrivate; + ByteVectorListPrivate *d; +}; + +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/toolkit/tbytevectorstream.cpp b/3rdparty/taglib/toolkit/tbytevectorstream.cpp index 39c3d82c1..03d7b919a 100644 --- a/3rdparty/taglib/toolkit/tbytevectorstream.cpp +++ b/3rdparty/taglib/toolkit/tbytevectorstream.cpp @@ -34,43 +34,35 @@ using namespace Strawberry_TagLib::TagLib; -class ByteVectorStream::ByteVectorStreamPrivate -{ -public: +class ByteVectorStream::ByteVectorStreamPrivate { + public: explicit ByteVectorStreamPrivate(const ByteVector &data); ByteVector data; long position; }; -ByteVectorStream::ByteVectorStreamPrivate::ByteVectorStreamPrivate(const ByteVector &_data) : - data(_data), - position(0) -{ +ByteVectorStream::ByteVectorStreamPrivate::ByteVectorStreamPrivate(const ByteVector &_data) : data(_data), + position(0) { } //////////////////////////////////////////////////////////////////////////////// // public members //////////////////////////////////////////////////////////////////////////////// -ByteVectorStream::ByteVectorStream(const ByteVector &data) : - d(new ByteVectorStreamPrivate(data)) -{ +ByteVectorStream::ByteVectorStream(const ByteVector &data) : d(new ByteVectorStreamPrivate(data)) { } -ByteVectorStream::~ByteVectorStream() -{ +ByteVectorStream::~ByteVectorStream() { delete d; } -FileName ByteVectorStream::name() const -{ - return FileName(""); // XXX do we need a name? +FileName ByteVectorStream::name() const { + return FileName(""); // XXX do we need a name? } -ByteVector ByteVectorStream::readBlock(unsigned long length) -{ - if(length == 0) +ByteVector ByteVectorStream::readBlock(unsigned long length) { + if (length == 0) return ByteVector(); ByteVector v = d->data.mid(d->position, length); @@ -78,25 +70,23 @@ ByteVector ByteVectorStream::readBlock(unsigned long length) return v; } -void ByteVectorStream::writeBlock(const ByteVector &data) -{ +void ByteVectorStream::writeBlock(const ByteVector &data) { unsigned int size = data.size(); - if(long(d->position + size) > length()) { + if (long(d->position + size) > length()) { truncate(d->position + size); } memcpy(d->data.data() + d->position, data.data(), size); d->position += size; } -void ByteVectorStream::insert(const ByteVector &data, unsigned long start, unsigned long replace) -{ +void ByteVectorStream::insert(const ByteVector &data, unsigned long start, unsigned long replace) { long sizeDiff = data.size() - replace; - if(sizeDiff < 0) { + if (sizeDiff < 0) { removeBlock(start + data.size(), -sizeDiff); } - else if(sizeDiff > 0) { + else if (sizeDiff > 0) { truncate(length() + sizeDiff); - unsigned long readPosition = start + replace; + unsigned long readPosition = start + replace; unsigned long writePosition = start + data.size(); memmove(d->data.data() + writePosition, d->data.data() + readPosition, length() - sizeDiff - readPosition); } @@ -104,11 +94,10 @@ void ByteVectorStream::insert(const ByteVector &data, unsigned long start, unsig writeBlock(data); } -void ByteVectorStream::removeBlock(unsigned long start, unsigned long length) -{ +void ByteVectorStream::removeBlock(unsigned long start, unsigned long length) { unsigned long readPosition = start + length; unsigned long writePosition = start; - if(readPosition < static_cast(ByteVectorStream::length())) { + if (readPosition < static_cast(ByteVectorStream::length())) { unsigned long bytesToMove = ByteVectorStream::length() - readPosition; memmove(d->data.data() + writePosition, d->data.data() + readPosition, bytesToMove); writePosition += bytesToMove; @@ -117,51 +106,43 @@ void ByteVectorStream::removeBlock(unsigned long start, unsigned long length) truncate(writePosition); } -bool ByteVectorStream::readOnly() const -{ +bool ByteVectorStream::readOnly() const { return false; } -bool ByteVectorStream::isOpen() const -{ +bool ByteVectorStream::isOpen() const { return true; } -void ByteVectorStream::seek(long offset, Position p) -{ - switch(p) { - case Beginning: - d->position = offset; - break; - case Current: - d->position += offset; - break; - case End: - d->position = length() + offset; // offset is expected to be negative - break; +void ByteVectorStream::seek(long offset, Position p) { + switch (p) { + case Beginning: + d->position = offset; + break; + case Current: + d->position += offset; + break; + case End: + d->position = length() + offset; // offset is expected to be negative + break; } } -void ByteVectorStream::clear() -{ +void ByteVectorStream::clear() { } -long ByteVectorStream::tell() const -{ +long ByteVectorStream::tell() const { return d->position; } -long ByteVectorStream::length() -{ +long ByteVectorStream::length() { return d->data.size(); } -void ByteVectorStream::truncate(long length) -{ +void ByteVectorStream::truncate(long length) { d->data.resize(length); } -ByteVector *ByteVectorStream::data() -{ +ByteVector *ByteVectorStream::data() { return &d->data; } diff --git a/3rdparty/taglib/toolkit/tbytevectorstream.h b/3rdparty/taglib/toolkit/tbytevectorstream.h index 68a120b34..0dba6b95f 100644 --- a/3rdparty/taglib/toolkit/tbytevectorstream.h +++ b/3rdparty/taglib/toolkit/tbytevectorstream.h @@ -34,37 +34,36 @@ namespace Strawberry_TagLib { namespace TagLib { - class String; - class Tag; - class AudioProperties; +class String; +class Tag; +class AudioProperties; - //! In-memory Stream class using ByteVector for its storage. +//! In-memory Stream class using ByteVector for its storage. - class TAGLIB_EXPORT ByteVectorStream : public IOStream - { - public: - /*! +class TAGLIB_EXPORT ByteVectorStream : public IOStream { + public: + /*! * Construct a File object and opens the \a file. \a file should be a * be a C-string in the local file system encoding. */ - ByteVectorStream(const ByteVector &data); + ByteVectorStream(const ByteVector &data); - /*! + /*! * Destroys this ByteVectorStream instance. */ - virtual ~ByteVectorStream(); + virtual ~ByteVectorStream(); - /*! + /*! * Returns the file name in the local file system encoding. */ - FileName name() const; + FileName name() const; - /*! + /*! * Reads a block of size \a length at the current get pointer. */ - ByteVector readBlock(unsigned long length); + ByteVector readBlock(unsigned long length); - /*! + /*! * Attempts to write the block \a data at the current get pointer. If the * file is currently only opened read only -- i.e. readOnly() returns true -- * this attempts to reopen the file in read/write mode. @@ -73,75 +72,74 @@ namespace TagLib { * for a ByteVector. And even this function is significantly slower than * doing output with a char[]. */ - void writeBlock(const ByteVector &data); + void writeBlock(const ByteVector &data); - /*! + /*! * Insert \a data at position \a start in the file overwriting \a replace * bytes of the original content. * * \note This method is slow since it requires rewriting all of the file * after the insertion point. */ - void insert(const ByteVector &data, unsigned long start = 0, unsigned long replace = 0); + void insert(const ByteVector &data, unsigned long start = 0, unsigned long replace = 0); - /*! + /*! * Removes a block of the file starting a \a start and continuing for * \a length bytes. * * \note This method is slow since it involves rewriting all of the file * after the removed portion. */ - void removeBlock(unsigned long start = 0, unsigned long length = 0); + void removeBlock(unsigned long start = 0, unsigned long length = 0); - /*! + /*! * Returns true if the file is read only (or if the file can not be opened). */ - bool readOnly() const; + bool readOnly() const; - /*! + /*! * Since the file can currently only be opened as an argument to the * constructor (sort-of by design), this returns if that open succeeded. */ - bool isOpen() const; + bool isOpen() const; - /*! + /*! * Move the I/O pointer to \a offset in the file from position \a p. This * defaults to seeking from the beginning of the file. * * \see Position */ - void seek(long offset, Position p = Beginning); + void seek(long offset, Position p = Beginning); - /*! + /*! * Reset the end-of-file and error flags on the file. */ - void clear(); + void clear(); - /*! + /*! * Returns the current offset within the file. */ - long tell() const; + long tell() const; - /*! + /*! * Returns the length of the file. */ - long length(); + long length(); - /*! + /*! * Truncates the file to a \a length. */ - void truncate(long length); + void truncate(long length); - ByteVector *data(); + ByteVector *data(); - protected: + protected: + private: + class ByteVectorStreamPrivate; + ByteVectorStreamPrivate *d; +}; - private: - class ByteVectorStreamPrivate; - ByteVectorStreamPrivate *d; - }; - -} -} +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/toolkit/tdebug.cpp b/3rdparty/taglib/toolkit/tdebug.cpp index 055469bf6..751689576 100644 --- a/3rdparty/taglib/toolkit/tdebug.cpp +++ b/3rdparty/taglib/toolkit/tdebug.cpp @@ -24,43 +24,40 @@ ***************************************************************************/ #ifdef HAVE_CONFIG_H -#include +# include #endif #if !defined(NDEBUG) || defined(TRACE_IN_RELEASE) -#include "tdebug.h" -#include "tstring.h" -#include "tdebuglistener.h" -#include "tutils.h" +# include "tdebug.h" +# include "tstring.h" +# include "tdebuglistener.h" +# include "tutils.h" -#include -#include -#include +# include +# include +# include namespace Strawberry_TagLib { -namespace TagLib -{ - // The instance is defined in tdebuglistener.cpp. - extern DebugListener *debugListener; +namespace TagLib { +// The instance is defined in tdebuglistener.cpp. +extern DebugListener *debugListener; - void debug(const String &s) - { - debugListener->printMessage("TagLib: " + s + "\n"); - } +void debug(const String &s) { + debugListener->printMessage("TagLib: " + s + "\n"); +} - void debugData(const ByteVector &v) - { - for(unsigned int i = 0; i < v.size(); ++i) { - const std::string bits = std::bitset<8>(v[i]).to_string(); - const String msg = Utils::formatString( - "*** [%u] - char '%c' - int %d, 0x%02x, 0b%s\n", - i, v[i], v[i], v[i], bits.c_str()); +void debugData(const ByteVector &v) { + for (unsigned int i = 0; i < v.size(); ++i) { + const std::string bits = std::bitset<8>(v[i]).to_string(); + const String msg = Utils::formatString( + "*** [%u] - char '%c' - int %d, 0x%02x, 0b%s\n", + i, v[i], v[i], v[i], bits.c_str()); - debugListener->printMessage(msg); - } + debugListener->printMessage(msg); } } -} +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/toolkit/tdebug.h b/3rdparty/taglib/toolkit/tdebug.h index 74b694ee0..a79633909 100644 --- a/3rdparty/taglib/toolkit/tdebug.h +++ b/3rdparty/taglib/toolkit/tdebug.h @@ -29,13 +29,13 @@ namespace Strawberry_TagLib { namespace TagLib { - class String; - class ByteVector; +class String; +class ByteVector; #ifndef DO_NOT_DOCUMENT -#if !defined(NDEBUG) || defined(TRACE_IN_RELEASE) +# if !defined(NDEBUG) || defined(TRACE_IN_RELEASE) - /*! +/*! * A simple function that outputs the debug messages to the listener. * The default listener redirects the messages to \a stderr when NDEBUG is * not defined. @@ -46,9 +46,9 @@ namespace TagLib { * * \internal */ - void debug(const String &s); +void debug(const String &s); - /*! +/*! * For debugging binary data. * * \warning Do not use this outside of TagLib, it could lead to undefined @@ -57,14 +57,14 @@ namespace TagLib { * * \internal */ - void debugData(const ByteVector &v); +void debugData(const ByteVector &v); -#else +# else - #define debug(x) ((void)0) - #define debugData(x) ((void)0) +# define debug(x) ((void)0) +# define debugData(x) ((void)0) -#endif +# endif } } diff --git a/3rdparty/taglib/toolkit/tdebuglistener.cpp b/3rdparty/taglib/toolkit/tdebuglistener.cpp index 20e1be307..cb90c8d64 100644 --- a/3rdparty/taglib/toolkit/tdebuglistener.cpp +++ b/3rdparty/taglib/toolkit/tdebuglistener.cpp @@ -29,59 +29,52 @@ #include #ifdef _WIN32 -# include +# include #endif using namespace Strawberry_TagLib::TagLib; -namespace -{ - class DefaultListener : public DebugListener - { - public: - virtual void printMessage(const String &msg) - { +namespace { +class DefaultListener : public DebugListener { + public: + virtual void printMessage(const String &msg) { #ifdef _WIN32 - const wstring wstr = msg.toWString(); - const int len = WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), -1, NULL, 0, NULL, NULL); - if(len != 0) { - std::vector buf(len); - WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), -1, &buf[0], len, NULL, NULL); + const wstring wstr = msg.toWString(); + const int len = WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), -1, NULL, 0, NULL, NULL); + if (len != 0) { + std::vector buf(len); + WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), -1, &buf[0], len, NULL, NULL); - std::cerr << std::string(&buf[0]); - } + std::cerr << std::string(&buf[0]); + } #else - std::cerr << msg; + std::cerr << msg; -#endif - } - }; +#endif + } +}; - DefaultListener defaultListener; -} +DefaultListener defaultListener; +} // namespace namespace Strawberry_TagLib { -namespace TagLib -{ - DebugListener *debugListener = &defaultListener; +namespace TagLib { +DebugListener *debugListener = &defaultListener; - DebugListener::DebugListener() - { - } - - DebugListener::~DebugListener() - { - } - - void setDebugListener(DebugListener *listener) - { - if(listener) - debugListener = listener; - else - debugListener = &defaultListener; - } +DebugListener::DebugListener() { } + +DebugListener::~DebugListener() { } + +void setDebugListener(DebugListener *listener) { + if (listener) + debugListener = listener; + else + debugListener = &defaultListener; +} +} // namespace TagLib +} // namespace Strawberry_TagLib diff --git a/3rdparty/taglib/toolkit/tdebuglistener.h b/3rdparty/taglib/toolkit/tdebuglistener.h index 4f7dad7a8..a7e2b19cf 100644 --- a/3rdparty/taglib/toolkit/tdebuglistener.h +++ b/3rdparty/taglib/toolkit/tdebuglistener.h @@ -30,36 +30,34 @@ #include "tstring.h" namespace Strawberry_TagLib { -namespace TagLib -{ - //! An abstraction for the listener to the debug messages. +namespace TagLib { +//! An abstraction for the listener to the debug messages. - /*! +/*! * This class enables you to handle the debug messages in your preferred * way by subclassing this class, reimplementing printMessage() and setting * your reimplementation as the default with setDebugListener(). * * \see setDebugListener() */ - class TAGLIB_EXPORT DebugListener - { - public: - DebugListener(); - virtual ~DebugListener(); +class TAGLIB_EXPORT DebugListener { + public: + DebugListener(); + virtual ~DebugListener(); - /*! + /*! * When overridden in a derived class, redirects \a msg to your preferred * channel such as stderr, Windows debugger or so forth. */ - virtual void printMessage(const String &msg) = 0; + virtual void printMessage(const String &msg) = 0; - private: - // Noncopyable - DebugListener(const DebugListener &); - DebugListener &operator=(const DebugListener &); - }; + private: + // Noncopyable + DebugListener(const DebugListener &); + DebugListener &operator=(const DebugListener &); +}; - /*! +/*! * Sets the listener that decides how the debug messages are redirected. * If the parameter \a listener is null, the previous listener is released * and default stderr listener is restored. @@ -69,8 +67,8 @@ namespace TagLib * * \see DebugListener */ - TAGLIB_EXPORT void setDebugListener(DebugListener *listener); -} -} +TAGLIB_EXPORT void setDebugListener(DebugListener *listener); +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/toolkit/tfile.cpp b/3rdparty/taglib/toolkit/tfile.cpp index f5ee2cbfc..d4ae28d44 100644 --- a/3rdparty/taglib/toolkit/tfile.cpp +++ b/3rdparty/taglib/toolkit/tfile.cpp @@ -30,18 +30,18 @@ #include "tpropertymap.h" #ifdef _WIN32 -# include -# include +# include +# include #else -# include -# include +# include +# include #endif #ifndef R_OK -# define R_OK 4 +# define R_OK 4 #endif #ifndef W_OK -# define W_OK 2 +# define W_OK 2 #endif #include "asffile.h" @@ -68,21 +68,18 @@ using namespace Strawberry_TagLib::TagLib; -class File::FilePrivate -{ -public: - FilePrivate(IOStream *_stream, bool _owner) : - stream(_stream), - streamOwner(_owner), - valid(true) {} +class File::FilePrivate { + public: + FilePrivate(IOStream* _stream, bool _owner) : stream(_stream), + streamOwner(_owner), + valid(true) {} - ~FilePrivate() - { - if(streamOwner) + ~FilePrivate() { + if (streamOwner) delete stream; } - IOStream *stream; + IOStream* stream; bool streamOwner; bool valid; }; @@ -91,166 +88,154 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -File::File(const FileName fileName) : - d(new FilePrivate(new FileStream(fileName), true)) -{ +File::File(const FileName fileName) : d(new FilePrivate(new FileStream(fileName), true)) { } -File::File(IOStream *stream) : - d(new FilePrivate(stream, false)) -{ +File::File(IOStream* stream) : d(new FilePrivate(stream, false)) { } -File::~File() -{ +File::~File() { delete d; } -FileName File::name() const -{ +FileName File::name() const { return d->stream->name(); } -PropertyMap File::properties() const -{ +PropertyMap File::properties() const { // ugly workaround until this method is virtual - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); + if (dynamic_cast(this)) + return dynamic_cast(this)->properties(); + if (dynamic_cast(this)) + return dynamic_cast(this)->properties(); + if (dynamic_cast(this)) + return dynamic_cast(this)->properties(); + if (dynamic_cast(this)) + return dynamic_cast(this)->properties(); + if (dynamic_cast(this)) + return dynamic_cast(this)->properties(); + if (dynamic_cast(this)) + return dynamic_cast(this)->properties(); + if (dynamic_cast(this)) + return dynamic_cast(this)->properties(); + if (dynamic_cast(this)) + return dynamic_cast(this)->properties(); + if (dynamic_cast(this)) + return dynamic_cast(this)->properties(); + if (dynamic_cast(this)) + return dynamic_cast(this)->properties(); + if (dynamic_cast(this)) + return dynamic_cast(this)->properties(); + if (dynamic_cast(this)) + return dynamic_cast(this)->properties(); + if (dynamic_cast(this)) + return dynamic_cast(this)->properties(); + if (dynamic_cast(this)) + return dynamic_cast(this)->properties(); + if (dynamic_cast(this)) + return dynamic_cast(this)->properties(); + if (dynamic_cast(this)) + return dynamic_cast(this)->properties(); + if (dynamic_cast(this)) + return dynamic_cast(this)->properties(); + if (dynamic_cast(this)) + return dynamic_cast(this)->properties(); + if (dynamic_cast(this)) + return dynamic_cast(this)->properties(); + if (dynamic_cast(this)) + return dynamic_cast(this)->properties(); return tag()->properties(); } -void File::removeUnsupportedProperties(const StringList &properties) -{ +void File::removeUnsupportedProperties(const StringList& properties) { // here we only consider those formats that could possibly contain // unsupported properties - if(dynamic_cast(this)) - dynamic_cast(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast(this)) - dynamic_cast(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast(this)) - dynamic_cast(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast(this)) - dynamic_cast(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast(this)) - dynamic_cast(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast(this)) - dynamic_cast(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast(this)) - dynamic_cast(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast(this)) - dynamic_cast(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast(this)) - dynamic_cast(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast(this)) - dynamic_cast(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast(this)) - dynamic_cast(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast(this)) - dynamic_cast(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast(this)) - dynamic_cast(this)->removeUnsupportedProperties(properties); + if (dynamic_cast(this)) + dynamic_cast(this)->removeUnsupportedProperties(properties); + else if (dynamic_cast(this)) + dynamic_cast(this)->removeUnsupportedProperties(properties); + else if (dynamic_cast(this)) + dynamic_cast(this)->removeUnsupportedProperties(properties); + else if (dynamic_cast(this)) + dynamic_cast(this)->removeUnsupportedProperties(properties); + else if (dynamic_cast(this)) + dynamic_cast(this)->removeUnsupportedProperties(properties); + else if (dynamic_cast(this)) + dynamic_cast(this)->removeUnsupportedProperties(properties); + else if (dynamic_cast(this)) + dynamic_cast(this)->removeUnsupportedProperties(properties); + else if (dynamic_cast(this)) + dynamic_cast(this)->removeUnsupportedProperties(properties); + else if (dynamic_cast(this)) + dynamic_cast(this)->removeUnsupportedProperties(properties); + else if (dynamic_cast(this)) + dynamic_cast(this)->removeUnsupportedProperties(properties); + else if (dynamic_cast(this)) + dynamic_cast(this)->removeUnsupportedProperties(properties); + else if (dynamic_cast(this)) + dynamic_cast(this)->removeUnsupportedProperties(properties); + else if (dynamic_cast(this)) + dynamic_cast(this)->removeUnsupportedProperties(properties); else tag()->removeUnsupportedProperties(properties); } -PropertyMap File::setProperties(const PropertyMap &properties) -{ - if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - else if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - else if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - else if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - else if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - else if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - else if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - else if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - else if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - else if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - else if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - else if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - else if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - else if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - else if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - else if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - else if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - else if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - else if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - else if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); +PropertyMap File::setProperties(const PropertyMap& properties) { + if (dynamic_cast(this)) + return dynamic_cast(this)->setProperties(properties); + else if (dynamic_cast(this)) + return dynamic_cast(this)->setProperties(properties); + else if (dynamic_cast(this)) + return dynamic_cast(this)->setProperties(properties); + else if (dynamic_cast(this)) + return dynamic_cast(this)->setProperties(properties); + else if (dynamic_cast(this)) + return dynamic_cast(this)->setProperties(properties); + else if (dynamic_cast(this)) + return dynamic_cast(this)->setProperties(properties); + else if (dynamic_cast(this)) + return dynamic_cast(this)->setProperties(properties); + else if (dynamic_cast(this)) + return dynamic_cast(this)->setProperties(properties); + else if (dynamic_cast(this)) + return dynamic_cast(this)->setProperties(properties); + else if (dynamic_cast(this)) + return dynamic_cast(this)->setProperties(properties); + else if (dynamic_cast(this)) + return dynamic_cast(this)->setProperties(properties); + else if (dynamic_cast(this)) + return dynamic_cast(this)->setProperties(properties); + else if (dynamic_cast(this)) + return dynamic_cast(this)->setProperties(properties); + else if (dynamic_cast(this)) + return dynamic_cast(this)->setProperties(properties); + else if (dynamic_cast(this)) + return dynamic_cast(this)->setProperties(properties); + else if (dynamic_cast(this)) + return dynamic_cast(this)->setProperties(properties); + else if (dynamic_cast(this)) + return dynamic_cast(this)->setProperties(properties); + else if (dynamic_cast(this)) + return dynamic_cast(this)->setProperties(properties); + else if (dynamic_cast(this)) + return dynamic_cast(this)->setProperties(properties); + else if (dynamic_cast(this)) + return dynamic_cast(this)->setProperties(properties); else return tag()->setProperties(properties); } -ByteVector File::readBlock(unsigned long length) -{ +ByteVector File::readBlock(unsigned long length) { return d->stream->readBlock(length); } -void File::writeBlock(const ByteVector &data) -{ +void File::writeBlock(const ByteVector& data) { d->stream->writeBlock(data); } -long File::find(const ByteVector &pattern, long fromOffset, const ByteVector &before) -{ - if(!d->stream || pattern.size() > bufferSize()) - return -1; +long File::find(const ByteVector& pattern, long fromOffset, const ByteVector& before) { + if (!d->stream || pattern.size() > bufferSize()) + return -1; // The position in the file that the current buffer starts at. @@ -290,21 +275,21 @@ long File::find(const ByteVector &pattern, long fromOffset, const ByteVector &be // then check for "before". The order is important because it gives priority // to "real" matches. - for(buffer = readBlock(bufferSize()); buffer.size() > 0; buffer = readBlock(bufferSize())) { + for (buffer = readBlock(bufferSize()); buffer.size() > 0; buffer = readBlock(bufferSize())) { // (1) previous partial match - if(previousPartialMatch >= 0 && int(bufferSize()) > previousPartialMatch) { + if (previousPartialMatch >= 0 && int(bufferSize()) > previousPartialMatch) { const int patternOffset = (bufferSize() - previousPartialMatch); - if(buffer.containsAt(pattern, 0, patternOffset)) { + if (buffer.containsAt(pattern, 0, patternOffset)) { seek(originalPosition); return bufferOffset - bufferSize() + previousPartialMatch; } } - if(!before.isEmpty() && beforePreviousPartialMatch >= 0 && int(bufferSize()) > beforePreviousPartialMatch) { + if (!before.isEmpty() && beforePreviousPartialMatch >= 0 && int(bufferSize()) > beforePreviousPartialMatch) { const int beforeOffset = (bufferSize() - beforePreviousPartialMatch); - if(buffer.containsAt(before, 0, beforeOffset)) { + if (buffer.containsAt(before, 0, beforeOffset)) { seek(originalPosition); return -1; } @@ -313,12 +298,12 @@ long File::find(const ByteVector &pattern, long fromOffset, const ByteVector &be // (2) pattern contained in current buffer long location = buffer.find(pattern); - if(location >= 0) { + if (location >= 0) { seek(originalPosition); return bufferOffset + location; } - if(!before.isEmpty() && buffer.find(before) >= 0) { + if (!before.isEmpty() && buffer.find(before) >= 0) { seek(originalPosition); return -1; } @@ -327,7 +312,7 @@ long File::find(const ByteVector &pattern, long fromOffset, const ByteVector &be previousPartialMatch = buffer.endsWithPartialMatch(pattern); - if(!before.isEmpty()) + if (!before.isEmpty()) beforePreviousPartialMatch = buffer.endsWithPartialMatch(before); bufferOffset += bufferSize(); @@ -343,10 +328,9 @@ long File::find(const ByteVector &pattern, long fromOffset, const ByteVector &be } -long File::rfind(const ByteVector &pattern, long fromOffset, const ByteVector &before) -{ - if(!d->stream || pattern.size() > bufferSize()) - return -1; +long File::rfind(const ByteVector& pattern, long fromOffset, const ByteVector& before) { + if (!d->stream || pattern.size() > bufferSize()) + return -1; // The position in the file that the current buffer starts at. @@ -367,7 +351,7 @@ long File::rfind(const ByteVector &pattern, long fromOffset, const ByteVector &b // Start the search at the offset. - if(fromOffset == 0) + if (fromOffset == 0) fromOffset = length(); long bufferLength = bufferSize(); @@ -375,9 +359,9 @@ long File::rfind(const ByteVector &pattern, long fromOffset, const ByteVector &b // See the notes in find() for an explanation of this algorithm. - while(true) { + while (true) { - if(bufferOffset > bufferLength) { + if (bufferOffset > bufferLength) { bufferOffset -= bufferLength; } else { @@ -387,7 +371,7 @@ long File::rfind(const ByteVector &pattern, long fromOffset, const ByteVector &b seek(bufferOffset); buffer = readBlock(bufferLength); - if(buffer.isEmpty()) + if (buffer.isEmpty()) break; // TODO: (1) previous partial match @@ -395,12 +379,12 @@ long File::rfind(const ByteVector &pattern, long fromOffset, const ByteVector &b // (2) pattern contained in current buffer const long location = buffer.rfind(pattern); - if(location >= 0) { + if (location >= 0) { seek(originalPosition); return bufferOffset + location; } - if(!before.isEmpty() && buffer.find(before) >= 0) { + if (!before.isEmpty() && buffer.find(before) >= 0) { seek(originalPosition); return -1; } @@ -417,58 +401,47 @@ long File::rfind(const ByteVector &pattern, long fromOffset, const ByteVector &b return -1; } -void File::insert(const ByteVector &data, unsigned long start, unsigned long replace) -{ +void File::insert(const ByteVector& data, unsigned long start, unsigned long replace) { d->stream->insert(data, start, replace); } -void File::removeBlock(unsigned long start, unsigned long length) -{ +void File::removeBlock(unsigned long start, unsigned long length) { d->stream->removeBlock(start, length); } -bool File::readOnly() const -{ +bool File::readOnly() const { return d->stream->readOnly(); } -bool File::isOpen() const -{ +bool File::isOpen() const { return d->stream->isOpen(); } -bool File::isValid() const -{ +bool File::isValid() const { return isOpen() && d->valid; } -void File::seek(long offset, Position p) -{ +void File::seek(long offset, Position p) { d->stream->seek(offset, IOStream::Position(p)); } -void File::truncate(long length) -{ +void File::truncate(long length) { d->stream->truncate(length); } -void File::clear() -{ +void File::clear() { d->stream->clear(); } -long File::tell() const -{ +long File::tell() const { return d->stream->tell(); } -long File::length() -{ +long File::length() { return d->stream->length(); } -bool File::isReadable(const char *file) -{ +bool File::isReadable(const char* file) { #if defined(_MSC_VER) && (_MSC_VER >= 1400) // VC++2005 or later @@ -479,11 +452,9 @@ bool File::isReadable(const char *file) return access(file, R_OK) == 0; #endif - } -bool File::isWritable(const char *file) -{ +bool File::isWritable(const char* file) { #if defined(_MSC_VER) && (_MSC_VER >= 1400) // VC++2005 or later @@ -494,20 +465,16 @@ bool File::isWritable(const char *file) return access(file, W_OK) == 0; #endif - } //////////////////////////////////////////////////////////////////////////////// // protected members //////////////////////////////////////////////////////////////////////////////// -unsigned int File::bufferSize() -{ +unsigned int File::bufferSize() { return 1024; } -void File::setValid(bool valid) -{ +void File::setValid(bool valid) { d->valid = valid; } - diff --git a/3rdparty/taglib/toolkit/tfile.h b/3rdparty/taglib/toolkit/tfile.h index 2ad35b944..e7ea94e23 100644 --- a/3rdparty/taglib/toolkit/tfile.h +++ b/3rdparty/taglib/toolkit/tfile.h @@ -35,68 +35,67 @@ namespace Strawberry_TagLib { namespace TagLib { - class String; - class Tag; - class AudioProperties; - class PropertyMap; +class String; +class Tag; +class AudioProperties; +class PropertyMap; - //! A file class with some useful methods for tag manipulation +//! A file class with some useful methods for tag manipulation - /*! +/*! * This class is a basic file class with some methods that are particularly * useful for tag editors. It has methods to take advantage of * ByteVector and a binary search method for finding patterns in a file. */ - class TAGLIB_EXPORT File - { - public: - /*! +class TAGLIB_EXPORT File { + public: + /*! * Position in the file used for seeking. */ - enum Position { - //! Seek from the beginning of the file. - Beginning, - //! Seek from the current position in the file. - Current, - //! Seek from the end of the file. - End - }; + enum Position { + //! Seek from the beginning of the file. + Beginning, + //! Seek from the current position in the file. + Current, + //! Seek from the end of the file. + End + }; - /*! + /*! * Specify which tags to strip either explicitly, or on save. */ - enum StripTags { - StripNone, // +# include #else -# include -# include +# include +# include #endif using namespace Strawberry_TagLib::TagLib; -namespace -{ +namespace { #ifdef _WIN32 - // Uses Win32 native API instead of POSIX API to reduce the resource consumption. +// Uses Win32 native API instead of POSIX API to reduce the resource consumption. - typedef FileName FileNameHandle; - typedef HANDLE FileHandle; +typedef FileName FileNameHandle; +typedef HANDLE FileHandle; - const FileHandle InvalidFileHandle = INVALID_HANDLE_VALUE; +const FileHandle InvalidFileHandle = INVALID_HANDLE_VALUE; - FileHandle openFile(const FileName &path, bool readOnly) - { - const DWORD access = readOnly ? GENERIC_READ : (GENERIC_READ | GENERIC_WRITE); +FileHandle openFile(const FileName &path, bool readOnly) { + const DWORD access = readOnly ? GENERIC_READ : (GENERIC_READ | GENERIC_WRITE); -#if defined (PLATFORM_WINRT) - return CreateFile2(path.wstr().c_str(), access, FILE_SHARE_READ, OPEN_EXISTING, NULL); -#else - return CreateFileW(path.wstr().c_str(), access, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); -#endif - } - - FileHandle openFile(const int, bool) - { - return InvalidFileHandle; - } - - void closeFile(FileHandle file) - { - CloseHandle(file); - } - - size_t readFile(FileHandle file, ByteVector &buffer) - { - DWORD length; - if(ReadFile(file, buffer.data(), static_cast(buffer.size()), &length, NULL)) - return static_cast(length); - else - return 0; - } - - size_t writeFile(FileHandle file, const ByteVector &buffer) - { - DWORD length; - if(WriteFile(file, buffer.data(), static_cast(buffer.size()), &length, NULL)) - return static_cast(length); - else - return 0; - } - -#else // _WIN32 - - struct FileNameHandle : public std::string - { - explicit FileNameHandle(FileName name) : std::string(name) {} - operator FileName () const { return c_str(); } - }; - - typedef FILE* FileHandle; - - const FileHandle InvalidFileHandle = 0; - - FileHandle openFile(const FileName &path, bool readOnly) - { - return fopen(path, readOnly ? "rb" : "rb+"); - } - - FileHandle openFile(const int fileDescriptor, bool readOnly) - { - return fdopen(fileDescriptor, readOnly ? "rb" : "rb+"); - } - - void closeFile(FileHandle file) - { - fclose(file); - } - - size_t readFile(FileHandle file, ByteVector &buffer) - { - return fread(buffer.data(), sizeof(char), buffer.size(), file); - } - - size_t writeFile(FileHandle file, const ByteVector &buffer) - { - return fwrite(buffer.data(), sizeof(char), buffer.size(), file); - } - -#endif // _WIN32 +# if defined(PLATFORM_WINRT) + return CreateFile2(path.wstr().c_str(), access, FILE_SHARE_READ, OPEN_EXISTING, NULL); +# else + return CreateFileW(path.wstr().c_str(), access, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); +# endif } -class FileStream::FileStreamPrivate -{ -public: +FileHandle openFile(const int, bool) { + return InvalidFileHandle; +} + +void closeFile(FileHandle file) { + CloseHandle(file); +} + +size_t readFile(FileHandle file, ByteVector &buffer) { + DWORD length; + if (ReadFile(file, buffer.data(), static_cast(buffer.size()), &length, NULL)) + return static_cast(length); + else + return 0; +} + +size_t writeFile(FileHandle file, const ByteVector &buffer) { + DWORD length; + if (WriteFile(file, buffer.data(), static_cast(buffer.size()), &length, NULL)) + return static_cast(length); + else + return 0; +} + +#else // _WIN32 + +struct FileNameHandle : public std::string { + explicit FileNameHandle(FileName name) : std::string(name) {} + operator FileName() const { return c_str(); } +}; + +typedef FILE *FileHandle; + +const FileHandle InvalidFileHandle = 0; + +FileHandle openFile(const FileName &path, bool readOnly) { + return fopen(path, readOnly ? "rb" : "rb+"); +} + +FileHandle openFile(const int fileDescriptor, bool readOnly) { + return fdopen(fileDescriptor, readOnly ? "rb" : "rb+"); +} + +void closeFile(FileHandle file) { + fclose(file); +} + +size_t readFile(FileHandle file, ByteVector &buffer) { + return fread(buffer.data(), sizeof(char), buffer.size(), file); +} + +size_t writeFile(FileHandle file, const ByteVector &buffer) { + return fwrite(buffer.data(), sizeof(char), buffer.size(), file); +} + +#endif // _WIN32 +} // namespace + +class FileStream::FileStreamPrivate { + public: explicit FileStreamPrivate(const FileName &fileName) - : file(InvalidFileHandle) - , name(fileName) - , readOnly(true) - { + : file(InvalidFileHandle), name(fileName), readOnly(true) { } FileHandle file; @@ -146,68 +130,63 @@ public: //////////////////////////////////////////////////////////////////////////////// FileStream::FileStream(FileName fileName, bool openReadOnly) - : d(new FileStreamPrivate(fileName)) -{ + : d(new FileStreamPrivate(fileName)) { // First try with read / write mode, if that fails, fall back to read only. - if(!openReadOnly) + if (!openReadOnly) d->file = openFile(fileName, false); - if(d->file != InvalidFileHandle) + if (d->file != InvalidFileHandle) d->readOnly = false; else d->file = openFile(fileName, true); - if(d->file == InvalidFileHandle) -# ifdef _WIN32 + if (d->file == InvalidFileHandle) +#ifdef _WIN32 debug("Could not open file " + fileName.toString()); -# else +#else debug("Could not open file " + String(static_cast(d->name))); -# endif +#endif } FileStream::FileStream(int fileDescriptor, bool openReadOnly) - : d(new FileStreamPrivate("")) -{ + : d(new FileStreamPrivate("")) { // First try with read / write mode, if that fails, fall back to read only. - if(!openReadOnly) + if (!openReadOnly) d->file = openFile(fileDescriptor, false); - if(d->file != InvalidFileHandle) + if (d->file != InvalidFileHandle) d->readOnly = false; else d->file = openFile(fileDescriptor, true); - if(d->file == InvalidFileHandle) + if (d->file == InvalidFileHandle) debug("Could not open file using file descriptor"); } -FileStream::~FileStream() -{ - if(isOpen()) +FileStream::~FileStream() { + if (isOpen()) closeFile(d->file); delete d; } -FileName FileStream::name() const -{ +FileName FileStream::name() const { return d->name; } -ByteVector FileStream::readBlock(unsigned long length) -{ - if(!isOpen()) { +ByteVector FileStream::readBlock(unsigned long length) { + if (!isOpen()) { debug("FileStream::readBlock() -- invalid file."); return ByteVector(); } - if(length == 0) + if (length == 0) return ByteVector(); const unsigned long streamLength = static_cast(FileStream::length()); - if(length > bufferSize() && length > streamLength) + if (length > bufferSize() && length > streamLength) length = streamLength; ByteVector buffer(static_cast(length)); @@ -218,14 +197,13 @@ ByteVector FileStream::readBlock(unsigned long length) return buffer; } -void FileStream::writeBlock(const ByteVector &data) -{ - if(!isOpen()) { +void FileStream::writeBlock(const ByteVector &data) { + if (!isOpen()) { debug("FileStream::writeBlock() -- invalid file."); return; } - if(readOnly()) { + if (readOnly()) { debug("FileStream::writeBlock() -- read only file."); return; } @@ -233,24 +211,23 @@ void FileStream::writeBlock(const ByteVector &data) writeFile(d->file, data); } -void FileStream::insert(const ByteVector &data, unsigned long start, unsigned long replace) -{ - if(!isOpen()) { +void FileStream::insert(const ByteVector &data, unsigned long start, unsigned long replace) { + if (!isOpen()) { debug("FileStream::insert() -- invalid file."); return; } - if(readOnly()) { + if (readOnly()) { debug("FileStream::insert() -- read only file."); return; } - if(data.size() == replace) { + if (data.size() == replace) { seek(start); writeBlock(data); return; } - else if(data.size() < replace) { + else if (data.size() < replace) { seek(start); writeBlock(data); removeBlock(start + data.size(), replace - data.size()); @@ -269,7 +246,7 @@ void FileStream::insert(const ByteVector &data, unsigned long start, unsigned lo unsigned long bufferLength = bufferSize(); - while(data.size() - replace > bufferLength) + while (data.size() - replace > bufferLength) bufferLength += bufferSize(); // Set where to start the reading and writing. @@ -280,7 +257,7 @@ void FileStream::insert(const ByteVector &data, unsigned long start, unsigned lo ByteVector buffer = data; ByteVector aboutToOverwrite(static_cast(bufferLength)); - while(true) { + while (true) { // Seek to the current read position and read the data that we're about // to overwrite. Appropriately increment the readPosition. @@ -292,7 +269,7 @@ void FileStream::insert(const ByteVector &data, unsigned long start, unsigned lo // Check to see if we just read the last block. We need to call clear() // if we did so that the last write succeeds. - if(bytesRead < bufferLength) + if (bytesRead < bufferLength) clear(); // Seek to the write position and write our buffer. Increment the @@ -303,7 +280,7 @@ void FileStream::insert(const ByteVector &data, unsigned long start, unsigned lo // We hit the end of the file. - if(bytesRead == 0) + if (bytesRead == 0) break; writePosition += buffer.size(); @@ -314,9 +291,8 @@ void FileStream::insert(const ByteVector &data, unsigned long start, unsigned lo } } -void FileStream::removeBlock(unsigned long start, unsigned long length) -{ - if(!isOpen()) { +void FileStream::removeBlock(unsigned long start, unsigned long length) { + if (!isOpen()) { debug("FileStream::removeBlock() -- invalid file."); return; } @@ -328,7 +304,7 @@ void FileStream::removeBlock(unsigned long start, unsigned long length) ByteVector buffer(static_cast(bufferLength)); - for(unsigned int bytesRead = -1; bytesRead != 0;) { + for (unsigned int bytesRead = -1; bytesRead != 0;) { seek(readPosition); bytesRead = static_cast(readFile(d->file, buffer)); readPosition += bytesRead; @@ -336,7 +312,7 @@ void FileStream::removeBlock(unsigned long start, unsigned long length) // Check to see if we just read the last block. We need to call clear() // if we did so that the last write succeeds. - if(bytesRead < buffer.size()) { + if (bytesRead < buffer.size()) { clear(); buffer.resize(bytesRead); } @@ -350,26 +326,23 @@ void FileStream::removeBlock(unsigned long start, unsigned long length) truncate(writePosition); } -bool FileStream::readOnly() const -{ +bool FileStream::readOnly() const { return d->readOnly; } -bool FileStream::isOpen() const -{ +bool FileStream::isOpen() const { return (d->file != InvalidFileHandle); } -void FileStream::seek(long offset, Position p) -{ - if(!isOpen()) { +void FileStream::seek(long offset, Position p) { + if (!isOpen()) { debug("FileStream::seek() -- invalid file."); return; } #ifdef _WIN32 - if(p != Beginning && p != Current && p != End) { + if (p != Beginning && p != Current && p != End) { debug("FileStream::seek() -- Invalid Position value."); return; } @@ -377,26 +350,26 @@ void FileStream::seek(long offset, Position p) LARGE_INTEGER liOffset; liOffset.QuadPart = offset; - if(!SetFilePointerEx(d->file, liOffset, NULL, static_cast(p))) { + if (!SetFilePointerEx(d->file, liOffset, NULL, static_cast(p))) { debug("FileStream::seek() -- Failed to set the file pointer."); } #else int whence; - switch(p) { - case Beginning: - whence = SEEK_SET; - break; - case Current: - whence = SEEK_CUR; - break; - case End: - whence = SEEK_END; - break; - default: - debug("FileStream::seek() -- Invalid Position value."); - return; + switch (p) { + case Beginning: + whence = SEEK_SET; + break; + case Current: + whence = SEEK_CUR; + break; + case End: + whence = SEEK_END; + break; + default: + debug("FileStream::seek() -- Invalid Position value."); + return; } fseek(d->file, offset, whence); @@ -404,8 +377,7 @@ void FileStream::seek(long offset, Position p) #endif } -void FileStream::clear() -{ +void FileStream::clear() { #ifdef _WIN32 // NOP @@ -417,15 +389,14 @@ void FileStream::clear() #endif } -long FileStream::tell() const -{ +long FileStream::tell() const { #ifdef _WIN32 const LARGE_INTEGER zero = {}; LARGE_INTEGER position; - if(SetFilePointerEx(d->file, zero, &position, FILE_CURRENT) && - position.QuadPart <= LONG_MAX) { + if (SetFilePointerEx(d->file, zero, &position, FILE_CURRENT) && + position.QuadPart <= LONG_MAX) { return static_cast(position.QuadPart); } else { @@ -440,9 +411,8 @@ long FileStream::tell() const #endif } -long FileStream::length() -{ - if(!isOpen()) { +long FileStream::length() { + if (!isOpen()) { debug("FileStream::length() -- invalid file."); return 0; } @@ -451,7 +421,7 @@ long FileStream::length() LARGE_INTEGER fileSize; - if(GetFileSizeEx(d->file, &fileSize) && fileSize.QuadPart <= LONG_MAX) { + if (GetFileSizeEx(d->file, &fileSize) && fileSize.QuadPart <= LONG_MAX) { return static_cast(fileSize.QuadPart); } else { @@ -477,15 +447,14 @@ long FileStream::length() // protected members //////////////////////////////////////////////////////////////////////////////// -void FileStream::truncate(long length) -{ +void FileStream::truncate(long length) { #ifdef _WIN32 const long currentPos = tell(); seek(length); - if(!SetEndOfFile(d->file)) { + if (!SetEndOfFile(d->file)) { debug("FileStream::truncate() -- Failed to truncate the file."); } @@ -495,13 +464,12 @@ void FileStream::truncate(long length) fflush(d->file); const int error = ftruncate(fileno(d->file), length); - if(error != 0) + if (error != 0) debug("FileStream::truncate() -- Coundn't truncate the file."); #endif } -unsigned int FileStream::bufferSize() -{ +unsigned int FileStream::bufferSize() { return 1024; } diff --git a/3rdparty/taglib/toolkit/tfilestream.h b/3rdparty/taglib/toolkit/tfilestream.h index 392a9701d..3594b7cc6 100644 --- a/3rdparty/taglib/toolkit/tfilestream.h +++ b/3rdparty/taglib/toolkit/tfilestream.h @@ -34,48 +34,47 @@ namespace Strawberry_TagLib { namespace TagLib { - class String; - class Tag; - class AudioProperties; +class String; +class Tag; +class AudioProperties; - //! A file class with some useful methods for tag manipulation +//! A file class with some useful methods for tag manipulation - /*! +/*! * This class is a basic file class with some methods that are particularly * useful for tag editors. It has methods to take advantage of * ByteVector and a binary search method for finding patterns in a file. */ - class TAGLIB_EXPORT FileStream : public IOStream - { - public: - /*! +class TAGLIB_EXPORT FileStream : public IOStream { + public: + /*! * Construct a File object and opens the \a file. \a file should be a * be a C-string in the local file system encoding. */ - FileStream(FileName file, bool openReadOnly = false); + FileStream(FileName file, bool openReadOnly = false); - /*! + /*! * Construct a File object and opens the \a file using file descriptor. */ - FileStream(int fileDescriptor, bool openReadOnly = false); + FileStream(int fileDescriptor, bool openReadOnly = false); - /*! + /*! * Destroys this FileStream instance. */ - virtual ~FileStream(); + virtual ~FileStream(); - /*! + /*! * Returns the file name in the local file system encoding. */ - FileName name() const; + FileName name() const; - /*! + /*! * Reads a block of size \a length at the current get pointer. */ - ByteVector readBlock(unsigned long length); + ByteVector readBlock(unsigned long length); - /*! + /*! * Attempts to write the block \a data at the current get pointer. If the * file is currently only opened read only -- i.e. readOnly() returns true -- * this attempts to reopen the file in read/write mode. @@ -84,78 +83,77 @@ namespace TagLib { * for a ByteVector. And even this function is significantly slower than * doing output with a char[]. */ - void writeBlock(const ByteVector &data); + void writeBlock(const ByteVector &data); - /*! + /*! * Insert \a data at position \a start in the file overwriting \a replace * bytes of the original content. * * \note This method is slow since it requires rewriting all of the file * after the insertion point. */ - void insert(const ByteVector &data, unsigned long start = 0, unsigned long replace = 0); + void insert(const ByteVector &data, unsigned long start = 0, unsigned long replace = 0); - /*! + /*! * Removes a block of the file starting a \a start and continuing for * \a length bytes. * * \note This method is slow since it involves rewriting all of the file * after the removed portion. */ - void removeBlock(unsigned long start = 0, unsigned long length = 0); + void removeBlock(unsigned long start = 0, unsigned long length = 0); - /*! + /*! * Returns true if the file is read only (or if the file can not be opened). */ - bool readOnly() const; + bool readOnly() const; - /*! + /*! * Since the file can currently only be opened as an argument to the * constructor (sort-of by design), this returns if that open succeeded. */ - bool isOpen() const; + bool isOpen() const; - /*! + /*! * Move the I/O pointer to \a offset in the file from position \a p. This * defaults to seeking from the beginning of the file. * * \see Position */ - void seek(long offset, Position p = Beginning); + void seek(long offset, Position p = Beginning); - /*! + /*! * Reset the end-of-file and error flags on the file. */ - void clear(); + void clear(); - /*! + /*! * Returns the current offset within the file. */ - long tell() const; + long tell() const; - /*! + /*! * Returns the length of the file. */ - long length(); + long length(); - /*! + /*! * Truncates the file to a \a length. */ - void truncate(long length); + void truncate(long length); - protected: - - /*! + protected: + /*! * Returns the buffer size that is used for internal buffering. */ - static unsigned int bufferSize(); + static unsigned int bufferSize(); - private: - class FileStreamPrivate; - FileStreamPrivate *d; - }; + private: + class FileStreamPrivate; + FileStreamPrivate *d; +}; -} -} +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/toolkit/tiostream.cpp b/3rdparty/taglib/toolkit/tiostream.cpp index 5c8df06bd..67bcfdad9 100644 --- a/3rdparty/taglib/toolkit/tiostream.cpp +++ b/3rdparty/taglib/toolkit/tiostream.cpp @@ -24,8 +24,8 @@ ***************************************************************************/ #ifdef _WIN32 -# include -# include +# include +# include #endif #include "tiostream.h" @@ -34,63 +34,50 @@ using namespace Strawberry_TagLib::TagLib; #ifdef _WIN32 -namespace -{ - std::wstring ansiToUnicode(const char *str) - { - const int len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); - if(len == 0) - return std::wstring(); +namespace { +std::wstring ansiToUnicode(const char *str) { + const int len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); + if (len == 0) + return std::wstring(); - std::wstring wstr(len - 1, L'\0'); - MultiByteToWideChar(CP_ACP, 0, str, -1, &wstr[0], len); + std::wstring wstr(len - 1, L'\0'); + MultiByteToWideChar(CP_ACP, 0, str, -1, &wstr[0], len); - return wstr; - } + return wstr; } +} // namespace // m_name is no longer used, but kept for backward compatibility. -FileName::FileName(const wchar_t *name) : - m_name(), - m_wname(name) -{ +FileName::FileName(const wchar_t *name) : m_name(), + m_wname(name) { } -FileName::FileName(const char *name) : - m_name(), - m_wname(ansiToUnicode(name)) -{ +FileName::FileName(const char *name) : m_name(), + m_wname(ansiToUnicode(name)) { } -FileName::FileName(const FileName &name) : - m_name(), - m_wname(name.m_wname) -{ +FileName::FileName(const FileName &name) : m_name(), + m_wname(name.m_wname) { } -FileName::operator const wchar_t *() const -{ +FileName::operator const wchar_t *() const { return m_wname.c_str(); } -FileName::operator const char *() const -{ +FileName::operator const char *() const { return m_name.c_str(); } -const std::wstring &FileName::wstr() const -{ +const std::wstring &FileName::wstr() const { return m_wname; } -const std::string &FileName::str() const -{ +const std::string &FileName::str() const { return m_name; } -String FileName::toString() const -{ +String FileName::toString() const { return String(m_wname.c_str()); } @@ -100,15 +87,11 @@ String FileName::toString() const // public members //////////////////////////////////////////////////////////////////////////////// -IOStream::IOStream() -{ +IOStream::IOStream() { } -IOStream::~IOStream() -{ +IOStream::~IOStream() { } -void IOStream::clear() -{ +void IOStream::clear() { } - diff --git a/3rdparty/taglib/toolkit/tiostream.h b/3rdparty/taglib/toolkit/tiostream.h index 7f9511e43..83846ccd0 100644 --- a/3rdparty/taglib/toolkit/tiostream.h +++ b/3rdparty/taglib/toolkit/tiostream.h @@ -34,65 +34,63 @@ namespace Strawberry_TagLib { namespace TagLib { #ifdef _WIN32 - class TAGLIB_EXPORT FileName - { - public: - FileName(const wchar_t *name); - FileName(const char *name); +class TAGLIB_EXPORT FileName { + public: + FileName(const wchar_t *name); + FileName(const char *name); - FileName(const FileName &name); + FileName(const FileName &name); - operator const wchar_t *() const; - operator const char *() const; + operator const wchar_t *() const; + operator const char *() const; - const std::wstring &wstr() const; - const std::string &str() const; + const std::wstring &wstr() const; + const std::string &str() const; - String toString() const; + String toString() const; - private: - const std::string m_name; - const std::wstring m_wname; - }; + private: + const std::string m_name; + const std::wstring m_wname; +}; #else - typedef const char *FileName; +typedef const char *FileName; #endif - //! An abstract class that provides operations on a sequence of bytes +//! An abstract class that provides operations on a sequence of bytes - class TAGLIB_EXPORT IOStream - { - public: - /*! +class TAGLIB_EXPORT IOStream { + public: + /*! * Position in the file used for seeking. */ - enum Position { - //! Seek from the beginning of the file. - Beginning, - //! Seek from the current position in the file. - Current, - //! Seek from the end of the file. - End - }; + enum Position { + //! Seek from the beginning of the file. + Beginning, + //! Seek from the current position in the file. + Current, + //! Seek from the end of the file. + End + }; - IOStream(); + IOStream(); - /*! + /*! * Destroys this IOStream instance. */ - virtual ~IOStream(); + virtual ~IOStream(); - /*! + /*! * Returns the stream name in the local file system encoding. */ - virtual FileName name() const = 0; + virtual FileName name() const = 0; - /*! + /*! * Reads a block of size \a length at the current get pointer. */ - virtual ByteVector readBlock(unsigned long length) = 0; + virtual ByteVector readBlock(unsigned long length) = 0; - /*! + /*! * Attempts to write the block \a data at the current get pointer. If the * file is currently only opened read only -- i.e. readOnly() returns true -- * this attempts to reopen the file in read/write mode. @@ -101,72 +99,72 @@ namespace TagLib { * for a ByteVector. And even this function is significantly slower than * doing output with a char[]. */ - virtual void writeBlock(const ByteVector &data) = 0; + virtual void writeBlock(const ByteVector &data) = 0; - /*! + /*! * Insert \a data at position \a start in the file overwriting \a replace * bytes of the original content. * * \note This method is slow since it requires rewriting all of the file * after the insertion point. */ - virtual void insert(const ByteVector &data, - unsigned long start = 0, unsigned long replace = 0) = 0; + virtual void insert(const ByteVector &data, + unsigned long start = 0, unsigned long replace = 0) = 0; - /*! + /*! * Removes a block of the file starting a \a start and continuing for * \a length bytes. * * \note This method is slow since it involves rewriting all of the file * after the removed portion. */ - virtual void removeBlock(unsigned long start = 0, unsigned long length = 0) = 0; + virtual void removeBlock(unsigned long start = 0, unsigned long length = 0) = 0; - /*! + /*! * Returns true if the file is read only (or if the file can not be opened). */ - virtual bool readOnly() const = 0; + virtual bool readOnly() const = 0; - /*! + /*! * Since the file can currently only be opened as an argument to the * constructor (sort-of by design), this returns if that open succeeded. */ - virtual bool isOpen() const = 0; + virtual bool isOpen() const = 0; - /*! + /*! * Move the I/O pointer to \a offset in the stream from position \a p. This * defaults to seeking from the beginning of the stream. * * \see Position */ - virtual void seek(long offset, Position p = Beginning) = 0; + virtual void seek(long offset, Position p = Beginning) = 0; - /*! + /*! * Reset the end-of-stream and error flags on the stream. */ - virtual void clear(); + virtual void clear(); - /*! + /*! * Returns the current offset within the stream. */ - virtual long tell() const = 0; + virtual long tell() const = 0; - /*! + /*! * Returns the length of the stream. */ - virtual long length() = 0; + virtual long length() = 0; - /*! + /*! * Truncates the stream to a \a length. */ - virtual void truncate(long length) = 0; + virtual void truncate(long length) = 0; - private: - IOStream(const IOStream &); - IOStream &operator=(const IOStream &); - }; + private: + IOStream(const IOStream &); + IOStream &operator=(const IOStream &); +}; -} -} +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/toolkit/tlist.h b/3rdparty/taglib/toolkit/tlist.h index c2abac95e..7cfe1b514 100644 --- a/3rdparty/taglib/toolkit/tlist.h +++ b/3rdparty/taglib/toolkit/tlist.h @@ -33,9 +33,9 @@ namespace Strawberry_TagLib { namespace TagLib { - //! A generic, implicitly shared list. +//! A generic, implicitly shared list. - /*! +/*! * This is basic generic list that's somewhere between a std::list and a * QValueList. This class is implicitly shared. For example: * @@ -51,155 +51,154 @@ namespace TagLib { * only \e then will the data be copied. */ - template class List - { - public: +template class List { + public: #ifndef DO_NOT_DOCUMENT - typedef typename std::list::iterator Iterator; - typedef typename std::list::const_iterator ConstIterator; + typedef typename std::list::iterator Iterator; + typedef typename std::list::const_iterator ConstIterator; #endif - /*! + /*! * Constructs an empty list. */ - List(); + List(); - /*! + /*! * Make a shallow, implicitly shared, copy of \a l. Because this is * implicitly shared, this method is lightweight and suitable for * pass-by-value usage. */ - List(const List &l); + List(const List &l); - /*! + /*! * Destroys this List instance. If auto deletion is enabled and this list * contains a pointer type all of the members are also deleted. */ - virtual ~List(); + virtual ~List(); - /*! + /*! * Returns an STL style iterator to the beginning of the list. See * std::list::const_iterator for the semantics. */ - Iterator begin(); + Iterator begin(); - /*! + /*! * Returns an STL style constant iterator to the beginning of the list. See * std::list::iterator for the semantics. */ - ConstIterator begin() const; + ConstIterator begin() const; - /*! + /*! * Returns an STL style iterator to the end of the list. See * std::list::iterator for the semantics. */ - Iterator end(); + Iterator end(); - /*! + /*! * Returns an STL style constant iterator to the end of the list. See * std::list::const_iterator for the semantics. */ - ConstIterator end() const; + ConstIterator end() const; - /*! + /*! * Inserts a copy of \a value before \a it. */ - Iterator insert(Iterator it, const T &value); + Iterator insert(Iterator it, const T &value); - /*! + /*! * Inserts the \a value into the list. This assumes that the list is * currently sorted. If \a unique is true then the value will not * be inserted if it is already in the list. */ - List &sortedInsert(const T &value, bool unique = false); + List &sortedInsert(const T &value, bool unique = false); - /*! + /*! * Appends \a item to the end of the list and returns a reference to the * list. */ - List &append(const T &item); + List &append(const T &item); - /*! + /*! * Appends all of the values in \a l to the end of the list and returns a * reference to the list. */ - List &append(const List &l); + List &append(const List &l); - /*! + /*! * Prepends \a item to the beginning list and returns a reference to the * list. */ - List &prepend(const T &item); + List &prepend(const T &item); - /*! + /*! * Prepends all of the items in \a l to the beginning list and returns a * reference to the list. */ - List &prepend(const List &l); + List &prepend(const List &l); - /*! + /*! * Clears the list. If auto deletion is enabled and this list contains a * pointer type the members are also deleted. * * \see setAutoDelete() */ - List &clear(); + List &clear(); - /*! + /*! * Returns the number of elements in the list. * * \see isEmpty() */ - unsigned int size() const; + unsigned int size() const; - /*! + /*! * Returns whether or not the list is empty. * * \see size() */ - bool isEmpty() const; + bool isEmpty() const; - /*! + /*! * Find the first occurrence of \a value. */ - Iterator find(const T &value); + Iterator find(const T &value); - /*! + /*! * Find the first occurrence of \a value. */ - ConstIterator find(const T &value) const; + ConstIterator find(const T &value) const; - /*! + /*! * Returns true if the list contains \a value. */ - bool contains(const T &value) const; + bool contains(const T &value) const; - /*! + /*! * Erase the item at \a it from the list. */ - Iterator erase(Iterator it); + Iterator erase(Iterator it); - /*! + /*! * Returns a reference to the first item in the list. */ - const T &front() const; + const T &front() const; - /*! + /*! * Returns a reference to the first item in the list. */ - T &front(); + T &front(); - /*! + /*! * Returns a reference to the last item in the list. */ - const T &back() const; + const T &back() const; - /*! + /*! * Returns a reference to the last item in the list. */ - T &back(); + T &back(); - /*! + /*! * Auto delete the members of the list when the last reference to the list * passes out of scope. This will have no effect on lists which do not * contain a pointer type. @@ -207,62 +206,62 @@ namespace TagLib { * \note This relies on partial template instantiation -- most modern C++ * compilers should now support this. */ - void setAutoDelete(bool autoDelete); + void setAutoDelete(bool autoDelete); - /*! + /*! * Returns a reference to item \a i in the list. * * \warning This method is slow. Use iterators to loop through the list. */ - T &operator[](unsigned int i); + T &operator[](unsigned int i); - /*! + /*! * Returns a const reference to item \a i in the list. * * \warning This method is slow. Use iterators to loop through the list. */ - const T &operator[](unsigned int i) const; + const T &operator[](unsigned int i) const; - /*! + /*! * Make a shallow, implicitly shared, copy of \a l. Because this is * implicitly shared, this method is lightweight and suitable for * pass-by-value usage. */ - List &operator=(const List &l); + List &operator=(const List &l); - /*! + /*! * Exchanges the content of this list by the content of \a l. */ - void swap(List &l); + void swap(List &l); - /*! + /*! * Compares this list with \a l and returns true if all of the elements are * the same. */ - bool operator==(const List &l) const; + bool operator==(const List &l) const; - /*! + /*! * Compares this list with \a l and returns true if the lists differ. */ - bool operator!=(const List &l) const; + bool operator!=(const List &l) const; - protected: - /* + protected: + /* * If this List is being shared via implicit sharing, do a deep copy of the * data and separate from the shared members. This should be called by all * non-const subclass members. */ - void detach(); + void detach(); - private: + private: #ifndef DO_NOT_DOCUMENT - template class ListPrivate; - ListPrivate *d; + template class ListPrivate; + ListPrivate *d; #endif - }; +}; -} -} +} // namespace TagLib +} // namespace Strawberry_TagLib // Since GCC doesn't support the "export" keyword, we have to include the // implementation. diff --git a/3rdparty/taglib/toolkit/tmap.h b/3rdparty/taglib/toolkit/tmap.h index 2f6918dbb..8869d87c9 100644 --- a/3rdparty/taglib/toolkit/tmap.h +++ b/3rdparty/taglib/toolkit/tmap.h @@ -33,170 +33,169 @@ namespace Strawberry_TagLib { namespace TagLib { - //! A generic, implicitly shared map. +//! A generic, implicitly shared map. - /*! +/*! * This implements a standard map container that associates a key with a value * and has fast key-based lookups. This map is also implicitly shared making * it suitable for pass-by-value usage. */ - template class Map - { - public: +template class Map { + public: #ifndef DO_NOT_DOCUMENT -#ifdef WANT_CLASS_INSTANTIATION_OF_MAP - // Some STL implementations get snippy over the use of the - // class keyword to distinguish different templates; Sun Studio - // in particular finds multiple specializations in certain rare - // cases and complains about that. GCC doesn't seem to mind, - // and uses the typedefs further below without the class keyword. - // Not all the specializations of Map can use the class keyword - // (when T is not actually a class type), so don't apply this - // generally. - typedef typename std::map::iterator Iterator; - typedef typename std::map::const_iterator ConstIterator; -#else - typedef typename std::map::iterator Iterator; - typedef typename std::map::const_iterator ConstIterator; -#endif +# ifdef WANT_CLASS_INSTANTIATION_OF_MAP + // Some STL implementations get snippy over the use of the + // class keyword to distinguish different templates; Sun Studio + // in particular finds multiple specializations in certain rare + // cases and complains about that. GCC doesn't seem to mind, + // and uses the typedefs further below without the class keyword. + // Not all the specializations of Map can use the class keyword + // (when T is not actually a class type), so don't apply this + // generally. + typedef typename std::map::iterator Iterator; + typedef typename std::map::const_iterator ConstIterator; +# else + typedef typename std::map::iterator Iterator; + typedef typename std::map::const_iterator ConstIterator; +# endif #endif - /*! + /*! * Constructs an empty Map. */ - Map(); + Map(); - /*! + /*! * Make a shallow, implicitly shared, copy of \a m. Because this is * implicitly shared, this method is lightweight and suitable for * pass-by-value usage. */ - Map(const Map &m); + Map(const Map &m); - /*! + /*! * Destroys this instance of the Map. */ - virtual ~Map(); + virtual ~Map(); - /*! + /*! * Returns an STL style iterator to the beginning of the map. See * std::map::iterator for the semantics. */ - Iterator begin(); + Iterator begin(); - /*! + /*! * Returns an STL style iterator to the beginning of the map. See * std::map::const_iterator for the semantics. */ - ConstIterator begin() const; + ConstIterator begin() const; - /*! + /*! * Returns an STL style iterator to the end of the map. See * std::map::iterator for the semantics. */ - Iterator end(); + Iterator end(); - /*! + /*! * Returns an STL style iterator to the end of the map. See * std::map::const_iterator for the semantics. */ - ConstIterator end() const; + ConstIterator end() const; - /*! + /*! * Inserts \a value under \a key in the map. If a value for \a key already * exists it will be overwritten. */ - Map &insert(const Key &key, const T &value); + Map &insert(const Key &key, const T &value); - /*! + /*! * Removes all of the elements from elements from the map. This however * will not delete pointers if the mapped type is a pointer type. */ - Map &clear(); + Map &clear(); - /*! + /*! * The number of elements in the map. * * \see isEmpty() */ - unsigned int size() const; + unsigned int size() const; - /*! + /*! * Returns true if the map is empty. * * \see size() */ - bool isEmpty() const; + bool isEmpty() const; - /*! + /*! * Find the first occurrence of \a key. */ - Iterator find(const Key &key); + Iterator find(const Key &key); - /*! + /*! * Find the first occurrence of \a key. */ - ConstIterator find(const Key &key) const; + ConstIterator find(const Key &key) const; - /*! + /*! * Returns true if the map contains an instance of \a key. */ - bool contains(const Key &key) const; + bool contains(const Key &key) const; - /*! + /*! * Erase the item at \a it from the list. */ - Map &erase(Iterator it); + Map &erase(Iterator it); - /*! + /*! * Erase the item with \a key from the list. */ - Map &erase(const Key &key); + Map &erase(const Key &key); - /*! + /*! * Returns a reference to the value associated with \a key. * * \note This has undefined behavior if the key is not present in the map. */ - const T &operator[](const Key &key) const; + const T &operator[](const Key &key) const; - /*! + /*! * Returns a reference to the value associated with \a key. * * \note This has undefined behavior if the key is not present in the map. */ - T &operator[](const Key &key); + T &operator[](const Key &key); - /*! + /*! * Make a shallow, implicitly shared, copy of \a m. Because this is * implicitly shared, this method is lightweight and suitable for * pass-by-value usage. */ - Map &operator=(const Map &m); + Map &operator=(const Map &m); - /*! + /*! * Exchanges the content of this map by the content of \a m. */ - void swap(Map &m); + void swap(Map &m); - protected: - /* + protected: + /* * If this List is being shared via implicit sharing, do a deep copy of the * data and separate from the shared members. This should be called by all * non-const subclass members. */ - void detach(); + void detach(); - private: + private: #ifndef DO_NOT_DOCUMENT - template class MapPrivate; - MapPrivate *d; + template class MapPrivate; + MapPrivate *d; #endif - }; +}; -} -} +} // namespace TagLib +} // namespace Strawberry_TagLib // Since GCC doesn't support the "export" keyword, we have to include the // implementation. diff --git a/3rdparty/taglib/toolkit/tpropertymap.cpp b/3rdparty/taglib/toolkit/tpropertymap.cpp index b354f9746..72c1d525f 100644 --- a/3rdparty/taglib/toolkit/tpropertymap.cpp +++ b/3rdparty/taglib/toolkit/tpropertymap.cpp @@ -32,14 +32,13 @@ PropertyMap::PropertyMap() : SimplePropertyMap() {} PropertyMap::PropertyMap(const SimplePropertyMap &m) { - for(SimplePropertyMap::ConstIterator it = m.begin(); it != m.end(); ++it){ + for (SimplePropertyMap::ConstIterator it = m.begin(); it != m.end(); ++it) { String key = it->first.upper(); - if(!key.isEmpty()) + if (!key.isEmpty()) insert(it->first, it->second); else unsupported.append(it->first); } - } PropertyMap::~PropertyMap() {} @@ -48,41 +47,35 @@ bool PropertyMap::insert(const String &key, const StringList &values) { String realKey = key.upper(); Iterator result = SimplePropertyMap::find(realKey); - if(result == end()) + if (result == end()) SimplePropertyMap::insert(realKey, values); else SimplePropertyMap::operator[](realKey).append(values); return true; - } -bool PropertyMap::replace(const String &key, const StringList &values) -{ +bool PropertyMap::replace(const String &key, const StringList &values) { String realKey = key.upper(); SimplePropertyMap::erase(realKey); SimplePropertyMap::insert(realKey, values); return true; } -PropertyMap::Iterator PropertyMap::find(const String &key) -{ +PropertyMap::Iterator PropertyMap::find(const String &key) { return SimplePropertyMap::find(key.upper()); } -PropertyMap::ConstIterator PropertyMap::find(const String &key) const -{ +PropertyMap::ConstIterator PropertyMap::find(const String &key) const { return SimplePropertyMap::find(key.upper()); } -bool PropertyMap::contains(const String &key) const -{ +bool PropertyMap::contains(const String &key) const { return SimplePropertyMap::contains(key.upper()); } -bool PropertyMap::contains(const PropertyMap &other) const -{ - for(ConstIterator it = other.begin(); it != other.end(); ++it) { - if(!SimplePropertyMap::contains(it->first)) +bool PropertyMap::contains(const PropertyMap &other) const { + for (ConstIterator it = other.begin(); it != other.end(); ++it) { + if (!SimplePropertyMap::contains(it->first)) return false; if ((*this)[it->first] != it->second) return false; @@ -90,84 +83,73 @@ bool PropertyMap::contains(const PropertyMap &other) const return true; } -PropertyMap &PropertyMap::erase(const String &key) -{ +PropertyMap &PropertyMap::erase(const String &key) { SimplePropertyMap::erase(key.upper()); return *this; } -PropertyMap &PropertyMap::erase(const PropertyMap &other) -{ - for(ConstIterator it = other.begin(); it != other.end(); ++it) +PropertyMap &PropertyMap::erase(const PropertyMap &other) { + for (ConstIterator it = other.begin(); it != other.end(); ++it) erase(it->first); return *this; } -PropertyMap &PropertyMap::merge(const PropertyMap &other) -{ - for(PropertyMap::ConstIterator it = other.begin(); it != other.end(); ++it) +PropertyMap &PropertyMap::merge(const PropertyMap &other) { + for (PropertyMap::ConstIterator it = other.begin(); it != other.end(); ++it) insert(it->first, it->second); unsupported.append(other.unsupported); return *this; } -const StringList &PropertyMap::operator[](const String &key) const -{ +const StringList &PropertyMap::operator[](const String &key) const { return SimplePropertyMap::operator[](key.upper()); } -StringList &PropertyMap::operator[](const String &key) -{ +StringList &PropertyMap::operator[](const String &key) { return SimplePropertyMap::operator[](key.upper()); } -bool PropertyMap::operator==(const PropertyMap &other) const -{ - for(ConstIterator it = other.begin(); it != other.end(); ++it) { +bool PropertyMap::operator==(const PropertyMap &other) const { + for (ConstIterator it = other.begin(); it != other.end(); ++it) { ConstIterator thisFind = find(it->first); - if( thisFind == end() || (thisFind->second != it->second) ) + if (thisFind == end() || (thisFind->second != it->second)) return false; } - for(ConstIterator it = begin(); it != end(); ++it) { + for (ConstIterator it = begin(); it != end(); ++it) { ConstIterator otherFind = other.find(it->first); - if( otherFind == other.end() || (otherFind->second != it->second) ) + if (otherFind == other.end() || (otherFind->second != it->second)) return false; } return unsupported == other.unsupported; } -bool PropertyMap::operator!=(const PropertyMap &other) const -{ +bool PropertyMap::operator!=(const PropertyMap &other) const { return !(*this == other); } -String PropertyMap::toString() const -{ +String PropertyMap::toString() const { String ret; - for(ConstIterator it = begin(); it != end(); ++it) - ret += it->first+"="+it->second.toString(", ") + "\n"; - if(!unsupported.isEmpty()) + for (ConstIterator it = begin(); it != end(); ++it) + ret += it->first + "=" + it->second.toString(", ") + "\n"; + if (!unsupported.isEmpty()) ret += "Unsupported Data: " + unsupported.toString(", ") + "\n"; return ret; } -void PropertyMap::removeEmpty() -{ +void PropertyMap::removeEmpty() { PropertyMap m; - for(ConstIterator it = begin(); it != end(); ++it) { - if(!it->second.isEmpty()) + for (ConstIterator it = begin(); it != end(); ++it) { + if (!it->second.isEmpty()) m.insert(it->first, it->second); } *this = m; } -StringList &PropertyMap::unsupportedData() -{ +StringList &PropertyMap::unsupportedData() { return unsupported; } -const StringList &PropertyMap::unsupportedData() const -{ +const StringList &PropertyMap::unsupportedData() const { return unsupported; } diff --git a/3rdparty/taglib/toolkit/tpropertymap.h b/3rdparty/taglib/toolkit/tpropertymap.h index 3303451b9..c3254edad 100644 --- a/3rdparty/taglib/toolkit/tpropertymap.h +++ b/3rdparty/taglib/toolkit/tpropertymap.h @@ -32,11 +32,11 @@ namespace Strawberry_TagLib { namespace TagLib { - typedef Map SimplePropertyMap; +typedef Map SimplePropertyMap; - //! A map for format-independent tag representations. +//! A map for format-independent tag representations. - /*! +/*! * This map implements a generic representation of textual audio metadata * ("tags") realized as pairs of a case-insensitive key * and a nonempty list of corresponding values, each value being an arbitrary @@ -106,108 +106,106 @@ namespace TagLib { * */ - class TAGLIB_EXPORT PropertyMap: public SimplePropertyMap - { - public: +class TAGLIB_EXPORT PropertyMap : public SimplePropertyMap { + public: + typedef SimplePropertyMap::Iterator Iterator; + typedef SimplePropertyMap::ConstIterator ConstIterator; - typedef SimplePropertyMap::Iterator Iterator; - typedef SimplePropertyMap::ConstIterator ConstIterator; + PropertyMap(); - PropertyMap(); - - /*! + /*! * Creates a PropertyMap initialized from a SimplePropertyMap. Copies all * entries from \a m that have valid keys. * Invalid keys will be appended to the unsupportedData() list. */ - PropertyMap(const SimplePropertyMap &m); + PropertyMap(const SimplePropertyMap &m); - virtual ~PropertyMap(); + virtual ~PropertyMap(); - /*! + /*! * Inserts \a values under \a key in the map. If \a key already exists, * then \a values will be appended to the existing StringList. * The returned value indicates success, i.e. whether \a key is a * valid key. */ - bool insert(const String &key, const StringList &values); + bool insert(const String &key, const StringList &values); - /*! + /*! * Replaces any existing values for \a key with the given \a values, * and simply insert them if \a key did not exist before. * The returned value indicates success, i.e. whether \a key is a * valid key. */ - bool replace(const String &key, const StringList &values); + bool replace(const String &key, const StringList &values); - /*! + /*! * Find the first occurrence of \a key. */ - Iterator find(const String &key); + Iterator find(const String &key); - /*! + /*! * Find the first occurrence of \a key. */ - ConstIterator find(const String &key) const; + ConstIterator find(const String &key) const; - /*! + /*! * Returns true if the map contains values for \a key. */ - bool contains(const String &key) const; + bool contains(const String &key) const; - /*! + /*! * Returns true if this map contains all keys of \a other * and the values coincide for that keys. Does not take * the unsupportedData list into account. */ - bool contains(const PropertyMap &other) const; + bool contains(const PropertyMap &other) const; - /*! + /*! * Erase the \a key and its values from the map. */ - PropertyMap &erase(const String &key); + PropertyMap &erase(const String &key); - /*! + /*! * Erases from this map all keys that appear in \a other. */ - PropertyMap &erase(const PropertyMap &other); + PropertyMap &erase(const PropertyMap &other); - /*! + /*! * Merge the contents of \a other into this PropertyMap. * If a key is contained in both maps, the values of the second * are appended to that of the first. * The unsupportedData() lists are concatenated as well. */ - PropertyMap &merge(const PropertyMap &other); + PropertyMap &merge(const PropertyMap &other); - /*! + /*! * Returns a reference to the value associated with \a key. * * \note: If \a key is not contained in the map, an empty * StringList is returned without error. */ - const StringList &operator[](const String &key) const; + const StringList &operator[](const String &key) const; - /*! + /*! * Returns a reference to the value associated with \a key. * * \note: If \a key is not contained in the map, an empty * StringList is returned. You can also directly add entries * by using this function as an lvalue. */ - StringList &operator[](const String &key); + StringList &operator[](const String &key); - /*! + /*! * Returns true if and only if \other has the same contents as this map. */ - bool operator==(const PropertyMap &other) const; + bool operator==(const PropertyMap &other) const; - /*! + /*! * Returns false if and only \other has the same contents as this map. */ - bool operator!=(const PropertyMap &other) const; + bool operator!=(const PropertyMap &other) const; - /*! + /*! * If a PropertyMap is read from a File object using File::properties(), * the StringList returned from this function will represent metadata * that could not be parsed into the PropertyMap representation. This could @@ -216,22 +214,20 @@ namespace TagLib { * those unsupported elements if you call File::setProperties() with the * same PropertyMap as argument. */ - StringList &unsupportedData(); - const StringList &unsupportedData() const; + StringList &unsupportedData(); + const StringList &unsupportedData() const; - /*! + /*! * Removes all entries which have an empty value list. */ - void removeEmpty(); + void removeEmpty(); - String toString() const; + String toString() const; - private: + private: + StringList unsupported; +}; - - StringList unsupported; - }; - -} -} +} // namespace TagLib +} // namespace Strawberry_TagLib #endif /* TAGLIB_PROPERTYMAP_H_ */ diff --git a/3rdparty/taglib/toolkit/trefcounter.cpp b/3rdparty/taglib/toolkit/trefcounter.cpp index 101908b29..78d50ee00 100644 --- a/3rdparty/taglib/toolkit/trefcounter.cpp +++ b/3rdparty/taglib/toolkit/trefcounter.cpp @@ -24,80 +24,71 @@ ***************************************************************************/ #ifdef HAVE_CONFIG_H -#include +# include #endif #include "trefcounter.h" #if defined(HAVE_STD_ATOMIC) -# include -# define ATOMIC_INT std::atomic_int -# define ATOMIC_INC(x) (++x) -# define ATOMIC_DEC(x) (--x) +# include +# define ATOMIC_INT std::atomic_int +# define ATOMIC_INC(x) (++x) +# define ATOMIC_DEC(x) (--x) #elif defined(HAVE_GCC_ATOMIC) -# define ATOMIC_INT int -# define ATOMIC_INC(x) __sync_add_and_fetch(&x, 1) -# define ATOMIC_DEC(x) __sync_sub_and_fetch(&x, 1) +# define ATOMIC_INT int +# define ATOMIC_INC(x) __sync_add_and_fetch(&x, 1) +# define ATOMIC_DEC(x) __sync_sub_and_fetch(&x, 1) #elif defined(HAVE_WIN_ATOMIC) -# if !defined(NOMINMAX) -# define NOMINMAX -# endif -# include -# define ATOMIC_INT long -# define ATOMIC_INC(x) InterlockedIncrement(&x) -# define ATOMIC_DEC(x) InterlockedDecrement(&x) +# if !defined(NOMINMAX) +# define NOMINMAX +# endif +# include +# define ATOMIC_INT long +# define ATOMIC_INC(x) InterlockedIncrement(&x) +# define ATOMIC_DEC(x) InterlockedDecrement(&x) #elif defined(HAVE_MAC_ATOMIC) -# include -# define ATOMIC_INT int32_t -# define ATOMIC_INC(x) OSAtomicIncrement32Barrier(&x) -# define ATOMIC_DEC(x) OSAtomicDecrement32Barrier(&x) +# include +# define ATOMIC_INT int32_t +# define ATOMIC_INC(x) OSAtomicIncrement32Barrier(&x) +# define ATOMIC_DEC(x) OSAtomicDecrement32Barrier(&x) #elif defined(HAVE_IA64_ATOMIC) -# include -# define ATOMIC_INT int -# define ATOMIC_INC(x) __sync_add_and_fetch(&x, 1) -# define ATOMIC_DEC(x) __sync_sub_and_fetch(&x, 1) +# include +# define ATOMIC_INT int +# define ATOMIC_INC(x) __sync_add_and_fetch(&x, 1) +# define ATOMIC_DEC(x) __sync_sub_and_fetch(&x, 1) #else -# define ATOMIC_INT int -# define ATOMIC_INC(x) (++x) -# define ATOMIC_DEC(x) (--x) +# define ATOMIC_INT int +# define ATOMIC_INC(x) (++x) +# define ATOMIC_DEC(x) (--x) #endif namespace Strawberry_TagLib { -namespace TagLib -{ +namespace TagLib { - class RefCounter::RefCounterPrivate - { - public: - RefCounterPrivate() : - refCount(1) {} +class RefCounter::RefCounterPrivate { + public: + RefCounterPrivate() : refCount(1) {} - volatile ATOMIC_INT refCount; - }; + volatile ATOMIC_INT refCount; +}; - RefCounter::RefCounter() : - d(new RefCounterPrivate()) - { - } - - RefCounter::~RefCounter() - { - delete d; - } - - void RefCounter::ref() - { - ATOMIC_INC(d->refCount); - } - - bool RefCounter::deref() - { - return (ATOMIC_DEC(d->refCount) == 0); - } - - int RefCounter::count() const - { - return static_cast(d->refCount); - } +RefCounter::RefCounter() : d(new RefCounterPrivate()) { } + +RefCounter::~RefCounter() { + delete d; } + +void RefCounter::ref() { + ATOMIC_INC(d->refCount); +} + +bool RefCounter::deref() { + return (ATOMIC_DEC(d->refCount) == 0); +} + +int RefCounter::count() const { + return static_cast(d->refCount); +} +} // namespace TagLib +} // namespace Strawberry_TagLib diff --git a/3rdparty/taglib/toolkit/trefcounter.h b/3rdparty/taglib/toolkit/trefcounter.h index bedbb0e0f..11fb015ca 100644 --- a/3rdparty/taglib/toolkit/trefcounter.h +++ b/3rdparty/taglib/toolkit/trefcounter.h @@ -39,17 +39,14 @@ # endif # include # define TAGLIB_ATOMIC_WIN -#elif defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 401) \ - && (defined(__i386__) || defined(__i486__) || defined(__i586__) || \ - defined(__i686__) || defined(__x86_64) || defined(__ia64)) \ - && !defined(__INTEL_COMPILER) +#elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 401) && (defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || defined(__x86_64) || defined(__ia64)) && !defined(__INTEL_COMPILER) # define TAGLIB_ATOMIC_GCC #elif defined(__ia64) && defined(__INTEL_COMPILER) # include # define TAGLIB_ATOMIC_GCC #endif -#ifndef DO_NOT_DOCUMENT // Tell Doxygen to skip this class. +#ifndef DO_NOT_DOCUMENT // Tell Doxygen to skip this class. /*! * \internal * This is just used as a base class for shared classes in TagLib. @@ -57,60 +54,68 @@ * \warning This is not part of the TagLib public API! */ namespace Strawberry_TagLib { -namespace TagLib -{ +namespace TagLib { - class TAGLIB_EXPORT RefCounter - { - public: - RefCounter(); - virtual ~RefCounter(); +class TAGLIB_EXPORT RefCounter { + public: + RefCounter(); + virtual ~RefCounter(); - void ref(); - bool deref(); - int count() const; + void ref(); + bool deref(); + int count() const; - private: - class RefCounterPrivate; - RefCounterPrivate *d; - }; + private: + class RefCounterPrivate; + RefCounterPrivate *d; +}; - // BIC this old class is needed by tlist.tcc and tmap.tcc - class RefCounterOld - { - public: - RefCounterOld() : refCount(1) {} +// BIC this old class is needed by tlist.tcc and tmap.tcc +class RefCounterOld { + public: + RefCounterOld() : refCount(1) {} -#ifdef TAGLIB_ATOMIC_MAC - void ref() { OSAtomicIncrement32Barrier(const_cast(&refCount)); } - bool deref() { return ! OSAtomicDecrement32Barrier(const_cast(&refCount)); } - int32_t count() { return refCount; } - private: - volatile int32_t refCount; -#elif defined(TAGLIB_ATOMIC_WIN) - void ref() { InterlockedIncrement(&refCount); } - bool deref() { return ! InterlockedDecrement(&refCount); } - long count() { return refCount; } - private: - volatile long refCount; -#elif defined(TAGLIB_ATOMIC_GCC) - void ref() { __sync_add_and_fetch(&refCount, 1); } - bool deref() { return ! __sync_sub_and_fetch(&refCount, 1); } - int count() { return refCount; } - private: - volatile int refCount; -#else - void ref() { refCount++; } - bool deref() { return ! --refCount; } - int count() { return refCount; } - private: - unsigned int refCount; +# ifdef TAGLIB_ATOMIC_MAC + void ref() { + OSAtomicIncrement32Barrier(const_cast(&refCount)); + } + bool deref() { return !OSAtomicDecrement32Barrier(const_cast(&refCount)); } + int32_t count() { return refCount; } + + private: + volatile int32_t refCount; +# elif defined(TAGLIB_ATOMIC_WIN) + void ref() { + InterlockedIncrement(&refCount); + } + bool deref() { return !InterlockedDecrement(&refCount); } + long count() { return refCount; } + + private: + volatile long refCount; +# elif defined(TAGLIB_ATOMIC_GCC) + void ref() { + __sync_add_and_fetch(&refCount, 1); + } + bool deref() { return !__sync_sub_and_fetch(&refCount, 1); } + int count() { return refCount; } + + private: + volatile int refCount; +# else + void ref() { + refCount++; + } + bool deref() { return !--refCount; } + int count() { return refCount; } + + private: + unsigned int refCount; +# endif +}; + +} // namespace TagLib +} // namespace Strawberry_TagLib + +#endif // DO_NOT_DOCUMENT #endif - }; - -} -} - -#endif // DO_NOT_DOCUMENT -#endif - diff --git a/3rdparty/taglib/toolkit/tstring.cpp b/3rdparty/taglib/toolkit/tstring.cpp index 4c706f557..c4ebbe6da 100644 --- a/3rdparty/taglib/toolkit/tstring.cpp +++ b/3rdparty/taglib/toolkit/tstring.cpp @@ -35,115 +35,105 @@ #include "tstring.h" -namespace -{ - using namespace Strawberry_TagLib::TagLib; +namespace { +using namespace Strawberry_TagLib::TagLib; - // Returns the native format of std::wstring. - String::Type wcharByteOrder() - { - if(Utils::systemByteOrder() == Utils::LittleEndian) - return String::UTF16LE; - else - return String::UTF16BE; - } +// Returns the native format of std::wstring. +String::Type wcharByteOrder() { + if (Utils::systemByteOrder() == Utils::LittleEndian) + return String::UTF16LE; + else + return String::UTF16BE; +} - // Converts a Latin-1 string into UTF-16(without BOM/CPU byte order) - // and copies it to the internal buffer. - void copyFromLatin1(std::wstring &data, const char *s, size_t length) - { - data.resize(length); +// Converts a Latin-1 string into UTF-16(without BOM/CPU byte order) +// and copies it to the internal buffer. +void copyFromLatin1(std::wstring &data, const char *s, size_t length) { + data.resize(length); - for(size_t i = 0; i < length; ++i) - data[i] = static_cast(s[i]); - } + for (size_t i = 0; i < length; ++i) + data[i] = static_cast(s[i]); +} - // Converts a UTF-8 string into UTF-16(without BOM/CPU byte order) - // and copies it to the internal buffer. - void copyFromUTF8(std::wstring &data, const char *s, size_t length) - { - data.resize(length); +// Converts a UTF-8 string into UTF-16(without BOM/CPU byte order) +// and copies it to the internal buffer. +void copyFromUTF8(std::wstring &data, const char *s, size_t length) { + data.resize(length); - try { - const std::wstring::iterator dstEnd = utf8::utf8to16(s, s + length, data.begin()); - data.resize(dstEnd - data.begin()); - } - catch(const utf8::exception &e) { - const String message(e.what()); - debug("String::copyFromUTF8() - UTF8-CPP error: " + message); - data.clear(); - } - } - - // Helper functions to read a UTF-16 character from an array. - template - unsigned short nextUTF16(const T **p); - - template <> - unsigned short nextUTF16(const wchar_t **p) - { - return static_cast(*(*p)++); - } - - template <> - unsigned short nextUTF16(const char **p) - { - union { - unsigned short w; - char c[2]; - } u; - u.c[0] = *(*p)++; - u.c[1] = *(*p)++; - return u.w; - } - - // Converts a UTF-16 (with BOM), UTF-16LE or UTF16-BE string into - // UTF-16(without BOM/CPU byte order) and copies it to the internal buffer. - template - void copyFromUTF16(std::wstring &data, const T *s, size_t length, String::Type t) - { - bool swap; - if(t == String::UTF16) { - if(length < 1) { - debug("String::copyFromUTF16() - Invalid UTF16 string. Too short to have a BOM."); - return; - } - - const unsigned short bom = nextUTF16(&s); - if(bom == 0xfeff) - swap = false; // Same as CPU endian. No need to swap bytes. - else if(bom == 0xfffe) - swap = true; // Not same as CPU endian. Need to swap bytes. - else { - debug("String::copyFromUTF16() - Invalid UTF16 string. BOM is broken."); - return; - } - - length--; - } - else { - swap = (t != wcharByteOrder()); - } - - data.resize(length); - for(size_t i = 0; i < length; ++i) { - const unsigned short c = nextUTF16(&s); - if(swap) - data[i] = Utils::byteSwap(c); - else - data[i] = c; - } + try { + const std::wstring::iterator dstEnd = utf8::utf8to16(s, s + length, data.begin()); + data.resize(dstEnd - data.begin()); + } catch (const utf8::exception &e) { + const String message(e.what()); + debug("String::copyFromUTF8() - UTF8-CPP error: " + message); + data.clear(); } } +// Helper functions to read a UTF-16 character from an array. +template +unsigned short nextUTF16(const T **p); + +template<> +unsigned short nextUTF16(const wchar_t **p) { + return static_cast(*(*p)++); +} + +template<> +unsigned short nextUTF16(const char **p) { + union { + unsigned short w; + char c[2]; + } u; + u.c[0] = *(*p)++; + u.c[1] = *(*p)++; + return u.w; +} + +// Converts a UTF-16 (with BOM), UTF-16LE or UTF16-BE string into +// UTF-16(without BOM/CPU byte order) and copies it to the internal buffer. +template +void copyFromUTF16(std::wstring &data, const T *s, size_t length, String::Type t) { + bool swap; + if (t == String::UTF16) { + if (length < 1) { + debug("String::copyFromUTF16() - Invalid UTF16 string. Too short to have a BOM."); + return; + } + + const unsigned short bom = nextUTF16(&s); + if (bom == 0xfeff) + swap = false; // Same as CPU endian. No need to swap bytes. + else if (bom == 0xfffe) + swap = true; // Not same as CPU endian. Need to swap bytes. + else { + debug("String::copyFromUTF16() - Invalid UTF16 string. BOM is broken."); + return; + } + + length--; + } + else { + swap = (t != wcharByteOrder()); + } + + data.resize(length); + for (size_t i = 0; i < length; ++i) { + const unsigned short c = nextUTF16(&s); + if (swap) + data[i] = Utils::byteSwap(c); + else + data[i] = c; + } +} +} // namespace + namespace Strawberry_TagLib { namespace TagLib { -class String::StringPrivate : public RefCounter -{ -public: - StringPrivate() : - RefCounter() {} +class String::StringPrivate : public RefCounter { + public: + StringPrivate() : RefCounter() {} /*! * Stores string in UTF-16. The byte order depends on the CPU endian. @@ -162,33 +152,25 @@ String String::null; // public members //////////////////////////////////////////////////////////////////////////////// -String::String() : - d(new StringPrivate()) -{ +String::String() : d(new StringPrivate()) { } -String::String(const String &s) : - d(s.d) -{ +String::String(const String &s) : d(s.d) { d->ref(); } -String::String(const std::string &s, Type t) : - d(new StringPrivate()) -{ - if(t == Latin1) +String::String(const std::string &s, Type t) : d(new StringPrivate()) { + if (t == Latin1) copyFromLatin1(d->data, s.c_str(), s.length()); - else if(t == String::UTF8) + else if (t == String::UTF8) copyFromUTF8(d->data, s.c_str(), s.length()); else { debug("String::String() -- std::string should not contain UTF16."); } } -String::String(const wstring &s, Type t) : - d(new StringPrivate()) -{ - if(t == UTF16 || t == UTF16BE || t == UTF16LE) { +String::String(const wstring &s, Type t) : d(new StringPrivate()) { + if (t == UTF16 || t == UTF16BE || t == UTF16LE) { // This looks ugly but needed for the compatibility with TagLib1.8. // Should be removed in TabLib2.0. if (t == UTF16BE) @@ -203,10 +185,8 @@ String::String(const wstring &s, Type t) : } } -String::String(const wchar_t *s, Type t) : - d(new StringPrivate()) -{ - if(t == UTF16 || t == UTF16BE || t == UTF16LE) { +String::String(const wchar_t *s, Type t) : d(new StringPrivate()) { + if (t == UTF16 || t == UTF16BE || t == UTF16LE) { // This looks ugly but needed for the compatibility with TagLib1.8. // Should be removed in TabLib2.0. if (t == UTF16BE) @@ -221,49 +201,41 @@ String::String(const wchar_t *s, Type t) : } } -String::String(const char *s, Type t) : - d(new StringPrivate()) -{ - if(t == Latin1) +String::String(const char *s, Type t) : d(new StringPrivate()) { + if (t == Latin1) copyFromLatin1(d->data, s, ::strlen(s)); - else if(t == String::UTF8) + else if (t == String::UTF8) copyFromUTF8(d->data, s, ::strlen(s)); else { debug("String::String() -- const char * should not contain UTF16."); } } -String::String(wchar_t c, Type t) : - d(new StringPrivate()) -{ - if(t == UTF16 || t == UTF16BE || t == UTF16LE) +String::String(wchar_t c, Type t) : d(new StringPrivate()) { + if (t == UTF16 || t == UTF16BE || t == UTF16LE) copyFromUTF16(d->data, &c, 1, t); else { debug("String::String() -- wchar_t should not contain Latin1 or UTF-8."); } } -String::String(char c, Type t) : - d(new StringPrivate()) -{ - if(t == Latin1) +String::String(char c, Type t) : d(new StringPrivate()) { + if (t == Latin1) copyFromLatin1(d->data, &c, 1); - else if(t == String::UTF8) + else if (t == String::UTF8) copyFromUTF8(d->data, &c, 1); else { debug("String::String() -- char should not contain UTF16."); } } -String::String(const ByteVector &v, Type t) : - d(new StringPrivate()) -{ - if(v.isEmpty()) +String::String(const ByteVector &v, Type t) : d(new StringPrivate()) { + if (v.isEmpty()) return; - if(t == Latin1) + if (t == Latin1) copyFromLatin1(d->data, v.data(), v.size()); - else if(t == UTF8) + else if (t == UTF8) copyFromUTF8(d->data, v.data(), v.size()); else copyFromUTF16(d->data, v.data(), v.size() / 2, t); @@ -274,72 +246,60 @@ String::String(const ByteVector &v, Type t) : //////////////////////////////////////////////////////////////////////////////// -String::~String() -{ - if(d->deref()) +String::~String() { + if (d->deref()) delete d; } -std::string String::to8Bit(bool unicode) const -{ +std::string String::to8Bit(bool unicode) const { const ByteVector v = data(unicode ? UTF8 : Latin1); return std::string(v.data(), v.size()); } -Strawberry_TagLib::TagLib::wstring String::toWString() const -{ +Strawberry_TagLib::TagLib::wstring String::toWString() const { return d->data; } -const char *String::toCString(bool unicode) const -{ +const char *String::toCString(bool unicode) const { d->cstring = to8Bit(unicode); return d->cstring.c_str(); } -const wchar_t *String::toCWString() const -{ +const wchar_t *String::toCWString() const { return d->data.c_str(); } -String::Iterator String::begin() -{ +String::Iterator String::begin() { detach(); return d->data.begin(); } -String::ConstIterator String::begin() const -{ +String::ConstIterator String::begin() const { return d->data.begin(); } -String::Iterator String::end() -{ +String::Iterator String::end() { detach(); return d->data.end(); } -String::ConstIterator String::end() const -{ +String::ConstIterator String::end() const { return d->data.end(); } -int String::find(const String &s, int offset) const -{ +int String::find(const String &s, int offset) const { return static_cast(d->data.find(s.d->data, offset)); } -int String::rfind(const String &s, int offset) const -{ +int String::rfind(const String &s, int offset) const { return static_cast(d->data.rfind(s.d->data, offset)); } -StringList String::split(const String &separator) const -{ +StringList String::split(const String &separator) const { StringList list; - for(int index = 0;;) { + for (int index = 0;;) { int sep = find(separator, index); - if(sep < 0) { + if (sep < 0) { list.append(substr(index, size() - index)); break; } @@ -351,42 +311,37 @@ StringList String::split(const String &separator) const return list; } -bool String::startsWith(const String &s) const -{ - if(s.length() > length()) +bool String::startsWith(const String &s) const { + if (s.length() > length()) return false; return substr(0, s.length()) == s; } -String String::substr(unsigned int position, unsigned int n) const -{ - if(position == 0 && n >= size()) +String String::substr(unsigned int position, unsigned int n) const { + if (position == 0 && n >= size()) return *this; else return String(d->data.substr(position, n)); } -String &String::append(const String &s) -{ +String &String::append(const String &s) { detach(); d->data += s.d->data; return *this; } -String & String::clear() -{ +String &String::clear() { *this = String(); return *this; } -String String::upper() const -{ +String String::upper() const { String s; s.d->data.reserve(size()); - for(ConstIterator it = begin(); it != end(); ++it) { - if(*it >= 'a' && *it <= 'z') + for (ConstIterator it = begin(); it != end(); ++it) { + if (*it >= 'a' && *it <= 'z') s.d->data.push_back(*it + 'A' - 'a'); else s.d->data.push_back(*it); @@ -395,49 +350,40 @@ String String::upper() const return s; } -unsigned int String::size() const -{ +unsigned int String::size() const { return static_cast(d->data.size()); } -unsigned int String::length() const -{ +unsigned int String::length() const { return size(); } -bool String::isEmpty() const -{ +bool String::isEmpty() const { return d->data.empty(); } -bool String::isNull() const -{ +bool String::isNull() const { return d == null.d; } -ByteVector String::data(Type t) const -{ - switch(t) - { - case Latin1: - { +ByteVector String::data(Type t) const { + switch (t) { + case Latin1: { ByteVector v(size(), 0); char *p = v.data(); - for(ConstIterator it = begin(); it != end(); ++it) + for (ConstIterator it = begin(); it != end(); ++it) *p++ = static_cast(*it); return v; } - case UTF8: - { + case UTF8: { ByteVector v(size() * 4, 0); try { const ByteVector::Iterator dstEnd = utf8::utf16to8(begin(), end(), v.begin()); v.resize(static_cast(dstEnd - v.begin())); - } - catch(const utf8::exception &e) { + } catch (const utf8::exception &e) { const String message(e.what()); debug("String::data() - UTF8-CPP error: " + message); v.clear(); @@ -445,8 +391,7 @@ ByteVector String::data(Type t) const return v; } - case UTF16: - { + case UTF16: { ByteVector v(2 + size() * 2, 0); char *p = v.data(); @@ -455,59 +400,54 @@ ByteVector String::data(Type t) const *p++ = '\xff'; *p++ = '\xfe'; - for(ConstIterator it = begin(); it != end(); ++it) { + for (ConstIterator it = begin(); it != end(); ++it) { *p++ = static_cast(*it & 0xff); *p++ = static_cast(*it >> 8); } return v; } - case UTF16BE: - { + case UTF16BE: { ByteVector v(size() * 2, 0); char *p = v.data(); - for(ConstIterator it = begin(); it != end(); ++it) { + for (ConstIterator it = begin(); it != end(); ++it) { *p++ = static_cast(*it >> 8); *p++ = static_cast(*it & 0xff); } return v; } - case UTF16LE: - { + case UTF16LE: { ByteVector v(size() * 2, 0); char *p = v.data(); - for(ConstIterator it = begin(); it != end(); ++it) { + for (ConstIterator it = begin(); it != end(); ++it) { *p++ = static_cast(*it & 0xff); *p++ = static_cast(*it >> 8); } return v; } - default: - { + default: { debug("String::data() - Invalid Type value."); return ByteVector(); } } } -int String::toInt() const -{ +int String::toInt() const { return toInt(0); } -int String::toInt(bool *ok) const -{ +int String::toInt(bool *ok) const { const wchar_t *begin = d->data.c_str(); wchar_t *end; errno = 0; const long value = ::wcstol(begin, &end, 10); // Has wcstol() consumed the entire string and not overflowed? - if(ok) { + if (ok) { *ok = (errno == 0 && end > begin && *end == L'\0'); *ok = (*ok && value > INT_MIN && value < INT_MAX); } @@ -515,186 +455,160 @@ int String::toInt(bool *ok) const return static_cast(value); } -String String::stripWhiteSpace() const -{ +String String::stripWhiteSpace() const { static const wchar_t *WhiteSpaceChars = L"\t\n\f\r "; const size_t pos1 = d->data.find_first_not_of(WhiteSpaceChars); - if(pos1 == std::wstring::npos) + if (pos1 == std::wstring::npos) return String(); const size_t pos2 = d->data.find_last_not_of(WhiteSpaceChars); return substr(static_cast(pos1), static_cast(pos2 - pos1 + 1)); } -bool String::isLatin1() const -{ - for(ConstIterator it = begin(); it != end(); ++it) { - if(*it >= 256) +bool String::isLatin1() const { + for (ConstIterator it = begin(); it != end(); ++it) { + if (*it >= 256) return false; } return true; } -bool String::isAscii() const -{ - for(ConstIterator it = begin(); it != end(); ++it) { - if(*it >= 128) +bool String::isAscii() const { + for (ConstIterator it = begin(); it != end(); ++it) { + if (*it >= 128) return false; } return true; } -String String::number(int n) // static +String String::number(int n) // static { return Utils::formatString("%d", n); } -wchar_t &String::operator[](int i) -{ +wchar_t &String::operator[](int i) { detach(); return d->data[i]; } -const wchar_t &String::operator[](int i) const -{ +const wchar_t &String::operator[](int i) const { return d->data[i]; } -bool String::operator==(const String &s) const -{ +bool String::operator==(const String &s) const { return (d == s.d || d->data == s.d->data); } -bool String::operator!=(const String &s) const -{ +bool String::operator!=(const String &s) const { return !(*this == s); } -bool String::operator==(const char *s) const -{ +bool String::operator==(const char *s) const { const wchar_t *p = toCWString(); - while(*p != L'\0' || *s != '\0') { - if(*p++ != static_cast(*s++)) + while (*p != L'\0' || *s != '\0') { + if (*p++ != static_cast(*s++)) return false; } return true; } -bool String::operator!=(const char *s) const -{ +bool String::operator!=(const char *s) const { return !(*this == s); } -bool String::operator==(const wchar_t *s) const -{ +bool String::operator==(const wchar_t *s) const { return (d->data == s); } -bool String::operator!=(const wchar_t *s) const -{ +bool String::operator!=(const wchar_t *s) const { return !(*this == s); } -String &String::operator+=(const String &s) -{ +String &String::operator+=(const String &s) { detach(); d->data += s.d->data; return *this; } -String &String::operator+=(const wchar_t *s) -{ +String &String::operator+=(const wchar_t *s) { detach(); d->data += s; return *this; } -String &String::operator+=(const char *s) -{ +String &String::operator+=(const char *s) { detach(); - for(int i = 0; s[i] != 0; i++) + for (int i = 0; s[i] != 0; i++) d->data += static_cast(s[i]); return *this; } -String &String::operator+=(wchar_t c) -{ +String &String::operator+=(wchar_t c) { detach(); d->data += c; return *this; } -String &String::operator+=(char c) -{ +String &String::operator+=(char c) { detach(); d->data += static_cast(c); return *this; } -String &String::operator=(const String &s) -{ +String &String::operator=(const String &s) { String(s).swap(*this); return *this; } -String &String::operator=(const std::string &s) -{ +String &String::operator=(const std::string &s) { String(s).swap(*this); return *this; } -String &String::operator=(const wstring &s) -{ +String &String::operator=(const wstring &s) { String(s).swap(*this); return *this; } -String &String::operator=(const wchar_t *s) -{ +String &String::operator=(const wchar_t *s) { String(s).swap(*this); return *this; } -String &String::operator=(char c) -{ +String &String::operator=(char c) { String(c).swap(*this); return *this; } -String &String::operator=(wchar_t c) -{ +String &String::operator=(wchar_t c) { String(c, wcharByteOrder()).swap(*this); return *this; } -String &String::operator=(const char *s) -{ +String &String::operator=(const char *s) { String(s).swap(*this); return *this; } -String &String::operator=(const ByteVector &v) -{ +String &String::operator=(const ByteVector &v) { String(v).swap(*this); return *this; } -void String::swap(String &s) -{ +void String::swap(String &s) { using std::swap; swap(d, s.d); } -bool String::operator<(const String &s) const -{ +bool String::operator<(const String &s) const { return (d->data < s.d->data); } @@ -702,9 +616,8 @@ bool String::operator<(const String &s) const // protected members //////////////////////////////////////////////////////////////////////////////// -void String::detach() -{ - if(d->count() > 1) +void String::detach() { + if (d->count() > 1) String(d->data.c_str()).swap(*this); } @@ -713,37 +626,32 @@ void String::detach() //////////////////////////////////////////////////////////////////////////////// const String::Type String::WCharByteOrder = wcharByteOrder(); -} -} +} // namespace TagLib +} // namespace Strawberry_TagLib //////////////////////////////////////////////////////////////////////////////// // related non-member functions //////////////////////////////////////////////////////////////////////////////// -const Strawberry_TagLib::TagLib::String operator+(const Strawberry_TagLib::TagLib::String &s1, const Strawberry_TagLib::TagLib::String &s2) -{ +const Strawberry_TagLib::TagLib::String operator+(const Strawberry_TagLib::TagLib::String &s1, const Strawberry_TagLib::TagLib::String &s2) { Strawberry_TagLib::TagLib::String s(s1); s.append(s2); return s; } -const Strawberry_TagLib::TagLib::String operator+(const char *s1, const Strawberry_TagLib::TagLib::String &s2) -{ +const Strawberry_TagLib::TagLib::String operator+(const char *s1, const Strawberry_TagLib::TagLib::String &s2) { Strawberry_TagLib::TagLib::String s(s1); s.append(s2); return s; } -const Strawberry_TagLib::TagLib::String operator+(const Strawberry_TagLib::TagLib::String &s1, const char *s2) -{ +const Strawberry_TagLib::TagLib::String operator+(const Strawberry_TagLib::TagLib::String &s1, const char *s2) { Strawberry_TagLib::TagLib::String s(s1); s.append(s2); return s; } -std::ostream &operator<<(std::ostream &s, const Strawberry_TagLib::TagLib::String &str) -{ +std::ostream &operator<<(std::ostream &s, const Strawberry_TagLib::TagLib::String &str) { s << str.to8Bit(); return s; } - diff --git a/3rdparty/taglib/toolkit/tstring.h b/3rdparty/taglib/toolkit/tstring.h index 1e2cf480f..a385a55b7 100644 --- a/3rdparty/taglib/toolkit/tstring.h +++ b/3rdparty/taglib/toolkit/tstring.h @@ -43,9 +43,9 @@ */ #if defined(QT_VERSION) && (QT_VERSION >= 0x040000) -#define QStringToTString(s) Strawberry_TagLib::TagLib::String(s.toUtf8().data(), Strawberry_TagLib::TagLib::String::UTF8) +# define QStringToTString(s) Strawberry_TagLib::TagLib::String(s.toUtf8().data(), Strawberry_TagLib::TagLib::String::UTF8) #else -#define QStringToTString(s) Strawberry_TagLib::TagLib::String(s.utf8().data(), Strawberry_TagLib::TagLib::String::UTF8) +# define QStringToTString(s) Strawberry_TagLib::TagLib::String(s.utf8().data(), Strawberry_TagLib::TagLib::String::UTF8) #endif /*! @@ -63,11 +63,11 @@ namespace Strawberry_TagLib { namespace TagLib { - class StringList; +class StringList; - //! A \e wide string class suitable for unicode. +//! A \e wide string class suitable for unicode. - /*! +/*! * This is an implicitly shared \e wide string. For storage it uses * TagLib::wstring, but as this is an implementation detail this of * course could change. Strings are stored internally as UTF-16(without BOM/ @@ -82,130 +82,128 @@ namespace TagLib { * possible encodings, which are the four supported by the ID3v2 standard. */ - class TAGLIB_EXPORT String - { - public: - +class TAGLIB_EXPORT String { + public: #ifndef DO_NOT_DOCUMENT - typedef Strawberry_TagLib::TagLib::wstring::iterator Iterator; - typedef Strawberry_TagLib::TagLib::wstring::const_iterator ConstIterator; + typedef Strawberry_TagLib::TagLib::wstring::iterator Iterator; + typedef Strawberry_TagLib::TagLib::wstring::const_iterator ConstIterator; #endif - /** + /** * The four types of string encodings supported by the ID3v2 specification. * ID3v1 is assumed to be Latin1 and Ogg Vorbis comments use UTF8. */ - enum Type { - /*! + enum Type { + /*! * IS08859-1, or Latin1 encoding. 8 bit characters. */ - Latin1 = 0, - /*! + Latin1 = 0, + /*! * UTF16 with a byte order mark. 16 bit characters. */ - UTF16 = 1, - /*! + UTF16 = 1, + /*! * UTF16 big endian. 16 bit characters. This is the encoding used * internally by TagLib. */ - UTF16BE = 2, - /*! + UTF16BE = 2, + /*! * UTF8 encoding. Characters are usually 8 bits but can be up to 32. */ - UTF8 = 3, - /*! + UTF8 = 3, + /*! * UTF16 little endian. 16 bit characters. */ - UTF16LE = 4 - }; + UTF16LE = 4 + }; - /*! + /*! * Constructs an empty String. */ - String(); + String(); - /*! + /*! * Make a shallow, implicitly shared, copy of \a s. Because this is * implicitly shared, this method is lightweight and suitable for * pass-by-value usage. */ - String(const String &s); + String(const String &s); - /*! + /*! * Makes a deep copy of the data in \a s. * * \note This should only be used with the 8-bit codecs Latin1 and UTF8, when * used with other codecs it will simply print a warning and exit. */ - String(const std::string &s, Type t = Latin1); + String(const std::string &s, Type t = Latin1); - /*! + /*! * Makes a deep copy of the data in \a s. * * /note If \a t is UTF16LE, the byte order of \a s will be swapped regardless * of the CPU byte order. If UTF16BE, it will not be swapped. This behavior * will be changed in TagLib2.0. */ - String(const wstring &s, Type t = UTF16BE); + String(const wstring &s, Type t = UTF16BE); - /*! + /*! * Makes a deep copy of the data in \a s. * * /note If \a t is UTF16LE, the byte order of \a s will be swapped regardless * of the CPU byte order. If UTF16BE, it will not be swapped. This behavior * will be changed in TagLib2.0. */ - String(const wchar_t *s, Type t = UTF16BE); + String(const wchar_t *s, Type t = UTF16BE); - /*! + /*! * Makes a deep copy of the data in \a c. * * \note This should only be used with the 8-bit codecs Latin1 and UTF8, when * used with other codecs it will simply print a warning and exit. */ - String(char c, Type t = Latin1); + String(char c, Type t = Latin1); - /*! + /*! * Makes a deep copy of the data in \a c. */ - String(wchar_t c, Type t = Latin1); + String(wchar_t c, Type t = Latin1); - /*! + /*! * Makes a deep copy of the data in \a s. * * \note This should only be used with the 8-bit codecs Latin1 and UTF8, when * used with other codecs it will simply print a warning and exit. */ - String(const char *s, Type t = Latin1); + String(const char *s, Type t = Latin1); - /*! + /*! * Makes a deep copy of the data in \a v. */ - String(const ByteVector &v, Type t = Latin1); + String(const ByteVector &v, Type t = Latin1); - /*! + /*! * Destroys this String instance. */ - virtual ~String(); + virtual ~String(); - /*! + /*! * Returns a deep copy of this String as an std::string. The returned string * is encoded in UTF8 if \a unicode is true, otherwise Latin1. * * \see toCString() */ - std::string to8Bit(bool unicode = false) const; + std::string to8Bit(bool unicode = false) const; - /*! + /*! * Returns a deep copy of this String as a wstring. The returned string is * encoded in UTF-16 (without BOM/CPU byte order), not UTF-32 even if wchar_t * is 32-bit wide. * * \see toCWString() */ - wstring toWString() const; + wstring toWString() const; - /*! + /*! * Creates and returns a standard C-style (null-terminated) version of this * String. The returned string is encoded in UTF8 if \a unicode is true, * otherwise Latin1. @@ -223,9 +221,9 @@ namespace TagLib { * * \see to8Bit() */ - const char *toCString(bool unicode = false) const; + const char *toCString(bool unicode = false) const; - /*! + /*! * Returns a standard C-style (null-terminated) wide character version of * this String. The returned string is encoded in UTF-16 (without BOM/CPU byte * order), not UTF-32 even if wchar_t is 32-bit wide. @@ -241,95 +239,95 @@ namespace TagLib { * * \see toWString() */ - const wchar_t *toCWString() const; + const wchar_t *toCWString() const; - /*! + /*! * Returns an iterator pointing to the beginning of the string. */ - Iterator begin(); + Iterator begin(); - /*! + /*! * Returns a const iterator pointing to the beginning of the string. */ - ConstIterator begin() const; + ConstIterator begin() const; - /*! + /*! * Returns an iterator pointing to the end of the string (the position * after the last character). */ - Iterator end(); + Iterator end(); - /*! + /*! * Returns a const iterator pointing to the end of the string (the position * after the last character). */ - ConstIterator end() const; + ConstIterator end() const; - /*! + /*! * Finds the first occurrence of pattern \a s in this string starting from * \a offset. If the pattern is not found, -1 is returned. */ - int find(const String &s, int offset = 0) const; + int find(const String &s, int offset = 0) const; - /*! + /*! * Finds the last occurrence of pattern \a s in this string, searched backwards, * either from the end of the string or starting from \a offset. If the pattern * is not found, -1 is returned. */ - int rfind(const String &s, int offset = -1) const; + int rfind(const String &s, int offset = -1) const; - /*! + /*! * Splits the string on each occurrence of \a separator. */ - StringList split(const String &separator = " ") const; + StringList split(const String &separator = " ") const; - /*! + /*! * Returns true if the strings starts with the substring \a s. */ - bool startsWith(const String &s) const; + bool startsWith(const String &s) const; - /*! + /*! * Extract a substring from this string starting at \a position and * continuing for \a n characters. */ - String substr(unsigned int position, unsigned int n = 0xffffffff) const; + String substr(unsigned int position, unsigned int n = 0xffffffff) const; - /*! + /*! * Append \a s to the current string and return a reference to the current * string. */ - String &append(const String &s); + String &append(const String &s); - /*! + /*! * Clears the string. */ - String &clear(); + String &clear(); - /*! + /*! * Returns an upper case version of the string. * * \warning This only works for the characters in US-ASCII, i.e. A-Z. */ - String upper() const; + String upper() const; - /*! + /*! * Returns the size of the string. */ - unsigned int size() const; + unsigned int size() const; - /*! + /*! * Returns the length of the string. Equivalent to size(). */ - unsigned int length() const; + unsigned int length() const; - /*! + /*! * Returns true if the string is empty. * * \see isNull() */ - bool isEmpty() const; + bool isEmpty() const; - /*! + /*! * Returns true if this string is null -- i.e. it is a copy of the * String::null string. * @@ -340,10 +338,10 @@ namespace TagLib { * * \deprecated */ - // BIC: remove - bool isNull() const; + // BIC: remove + bool isNull() const; - /*! + /*! * Returns a ByteVector containing the string's data. If \a t is Latin1 or * UTF8, this will return a vector of 8 bit characters, otherwise it will use * 16 bit characters. @@ -353,171 +351,171 @@ namespace TagLib { * * \note The returned data is not null terminated. */ - ByteVector data(Type t) const; + ByteVector data(Type t) const; - /*! + /*! * Convert the string to an integer. * * Returns the integer if the conversion was successful or 0 if the * string does not represent a number. */ - // BIC: merge with the method below - int toInt() const; + // BIC: merge with the method below + int toInt() const; - /*! + /*! * Convert the string to an integer. * * If the conversion was successful, it sets the value of \a *ok to * true and returns the integer. Otherwise it sets \a *ok to false * and the result is undefined. */ - int toInt(bool *ok) const; + int toInt(bool *ok) const; - /*! + /*! * Returns a string with the leading and trailing whitespace stripped. */ - String stripWhiteSpace() const; + String stripWhiteSpace() const; - /*! + /*! * Returns true if the file only uses characters required by Latin1. */ - bool isLatin1() const; + bool isLatin1() const; - /*! + /*! * Returns true if the file only uses characters required by (7-bit) ASCII. */ - bool isAscii() const; + bool isAscii() const; - /*! + /*! * Converts the base-10 integer \a n to a string. */ - static String number(int n); + static String number(int n); - /*! + /*! * Returns a reference to the character at position \a i. */ - wchar_t &operator[](int i); + wchar_t &operator[](int i); - /*! + /*! * Returns a const reference to the character at position \a i. */ - const wchar_t &operator[](int i) const; + const wchar_t &operator[](int i) const; - /*! + /*! * Compares each character of the String with each character of \a s and * returns true if the strings match. */ - bool operator==(const String &s) const; + bool operator==(const String &s) const; - /*! + /*! * Compares each character of the String with each character of \a s and * returns false if the strings match. */ - bool operator!=(const String &s) const; + bool operator!=(const String &s) const; - /*! + /*! * Compares each character of the String with each character of \a s and * returns true if the strings match. */ - bool operator==(const char *s) const; + bool operator==(const char *s) const; - /*! + /*! * Compares each character of the String with each character of \a s and * returns false if the strings match. */ - bool operator!=(const char *s) const; + bool operator!=(const char *s) const; - /*! + /*! * Compares each character of the String with each character of \a s and * returns true if the strings match. */ - bool operator==(const wchar_t *s) const; + bool operator==(const wchar_t *s) const; - /*! + /*! * Compares each character of the String with each character of \a s and * returns false if the strings match. */ - bool operator!=(const wchar_t *s) const; + bool operator!=(const wchar_t *s) const; - /*! + /*! * Appends \a s to the end of the String. */ - String &operator+=(const String &s); + String &operator+=(const String &s); - /*! + /*! * Appends \a s to the end of the String. */ - String &operator+=(const wchar_t* s); + String &operator+=(const wchar_t *s); - /*! + /*! * Appends \a s to the end of the String. */ - String &operator+=(const char* s); + String &operator+=(const char *s); - /*! + /*! * Appends \a s to the end of the String. */ - String &operator+=(wchar_t c); + String &operator+=(wchar_t c); - /*! + /*! * Appends \a c to the end of the String. */ - String &operator+=(char c); + String &operator+=(char c); - /*! + /*! * Performs a shallow, implicitly shared, copy of \a s, overwriting the * String's current data. */ - String &operator=(const String &s); + String &operator=(const String &s); - /*! + /*! * Performs a deep copy of the data in \a s. */ - String &operator=(const std::string &s); + String &operator=(const std::string &s); - /*! + /*! * Performs a deep copy of the data in \a s. */ - String &operator=(const wstring &s); + String &operator=(const wstring &s); - /*! + /*! * Performs a deep copy of the data in \a s. */ - String &operator=(const wchar_t *s); + String &operator=(const wchar_t *s); - /*! + /*! * Performs a deep copy of the data in \a s. */ - String &operator=(char c); + String &operator=(char c); - /*! + /*! * Performs a deep copy of the data in \a s. */ - String &operator=(wchar_t c); + String &operator=(wchar_t c); - /*! + /*! * Performs a deep copy of the data in \a s. */ - String &operator=(const char *s); + String &operator=(const char *s); - /*! + /*! * Performs a deep copy of the data in \a v. */ - String &operator=(const ByteVector &v); + String &operator=(const ByteVector &v); - /*! + /*! * Exchanges the content of the String by the content of \a s. */ - void swap(String &s); + void swap(String &s); - /*! + /*! * To be able to use this class in a Map, this operator needed to be * implemented. Returns true if \a s is less than this string in a byte-wise * comparison. */ - bool operator<(const String &s) const; + bool operator<(const String &s) const; - /*! + /*! * A null string provided for convenience. * * \warning Do not modify this variable. It will mess up the internal state @@ -525,31 +523,31 @@ namespace TagLib { * * \deprecated */ - // BIC: remove - static String null; + // BIC: remove + static String null; - protected: - /*! + protected: + /*! * If this String is being shared via implicit sharing, do a deep copy of the * data and separate from the shared members. This should be called by all * non-const subclass members. */ - void detach(); + void detach(); - private: - /*! + private: + /*! * \deprecated This variable is no longer used, but NEVER remove this. It * may lead to a linkage error. */ - // BIC: remove - TAGLIB_DEPRECATED static const Type WCharByteOrder; + // BIC: remove + TAGLIB_DEPRECATED static const Type WCharByteOrder; - class StringPrivate; - StringPrivate *d; - }; + class StringPrivate; + StringPrivate *d; +}; -} -} +} // namespace TagLib +} // namespace Strawberry_TagLib /*! * \relates TagLib::String diff --git a/3rdparty/taglib/toolkit/tstringlist.cpp b/3rdparty/taglib/toolkit/tstringlist.cpp index ab8d07ed0..797a9a2cb 100644 --- a/3rdparty/taglib/toolkit/tstringlist.cpp +++ b/3rdparty/taglib/toolkit/tstringlist.cpp @@ -27,21 +27,18 @@ using namespace Strawberry_TagLib::TagLib; -class StringListPrivate -{ - +class StringListPrivate { }; //////////////////////////////////////////////////////////////////////////////// // static members //////////////////////////////////////////////////////////////////////////////// -StringList StringList::split(const String &s, const String &pattern) -{ +StringList StringList::split(const String &s, const String &pattern) { StringList l; int previousOffset = 0; - for(int offset = s.find(pattern); offset != -1; offset = s.find(pattern, offset + 1)) { + for (int offset = s.find(pattern); offset != -1; offset = s.find(pattern, offset + 1)) { l.append(s.substr(previousOffset, offset - previousOffset)); previousOffset = offset + 1; } @@ -55,58 +52,47 @@ StringList StringList::split(const String &s, const String &pattern) // public members //////////////////////////////////////////////////////////////////////////////// -StringList::StringList() : - List(), - d(nullptr) -{ - +StringList::StringList() : List(), + d(nullptr) { } -StringList::StringList(const String &s) : - List(), - d(nullptr) -{ +StringList::StringList(const String &s) : List(), + d(nullptr) { append(s); } -StringList::StringList(const ByteVectorList &bl, String::Type t) : List() -{ +StringList::StringList(const ByteVectorList &bl, String::Type t) : List() { ByteVectorList::ConstIterator i = bl.begin(); - for(;i != bl.end(); i++) { + for (; i != bl.end(); i++) { append(String(*i, t)); } } -StringList::~StringList() -{ - +StringList::~StringList() { } -String StringList::toString(const String &separator) const -{ +String StringList::toString(const String &separator) const { String s; ConstIterator it = begin(); ConstIterator itEnd = end(); - while(it != itEnd) { + while (it != itEnd) { s += *it; it++; - if(it != itEnd) + if (it != itEnd) s += separator; } return s; } -StringList &StringList::append(const String &s) -{ +StringList &StringList::append(const String &s) { List::append(s); return *this; } -StringList &StringList::append(const StringList &l) -{ +StringList &StringList::append(const StringList &l) { List::append(l); return *this; } @@ -115,8 +101,7 @@ StringList &StringList::append(const StringList &l) // related functions //////////////////////////////////////////////////////////////////////////////// -std::ostream &operator<<(std::ostream &s, const StringList &l) -{ +std::ostream &operator<<(std::ostream &s, const StringList &l) { s << l.toString(); return s; } diff --git a/3rdparty/taglib/toolkit/tstringlist.h b/3rdparty/taglib/toolkit/tstringlist.h index a1770b464..28d60e837 100644 --- a/3rdparty/taglib/toolkit/tstringlist.h +++ b/3rdparty/taglib/toolkit/tstringlist.h @@ -36,77 +36,75 @@ namespace Strawberry_TagLib { namespace TagLib { - //! A list of strings +//! A list of strings - /*! +/*! * This is a specialization of the List class with some members convention for * string operations. */ - class TAGLIB_EXPORT StringList : public List - { - public: - - /*! +class TAGLIB_EXPORT StringList : public List { + public: + /*! * Constructs an empty StringList. */ - StringList(); + StringList(); - /*! + /*! * Make a shallow, implicitly shared, copy of \a l. Because this is * implicitly shared, this method is lightweight and suitable for * pass-by-value usage. */ - StringList(const StringList &l) = default; + StringList(const StringList &l) = default; - /*! + /*! * Constructs a StringList with \a s as a member. */ - StringList(const String &s); + StringList(const String &s); - /*! + /*! * Makes a deep copy of the data in \a vl. * * \note This should only be used with the 8-bit codecs Latin1 and UTF8, when * used with other codecs it will simply print a warning and exit. */ - StringList(const ByteVectorList &vl, String::Type t = String::Latin1); + StringList(const ByteVectorList &vl, String::Type t = String::Latin1); - /*! + /*! * Destroys this StringList instance. */ - virtual ~StringList(); + virtual ~StringList(); - /*! + /*! * Concatenate the list of strings into one string separated by \a separator. */ - String toString(const String &separator = " ") const; + String toString(const String &separator = " ") const; - /*! + /*! * Appends \a s to the end of the list and returns a reference to the * list. */ - StringList &append(const String &s); + StringList &append(const String &s); - /*! + /*! * Appends all of the values in \a l to the end of the list and returns a * reference to the list. */ - StringList &append(const StringList &l); + StringList &append(const StringList &l); - /*! + /*! * Splits the String \a s into several strings at \a pattern. This will not include * the pattern in the returned strings. */ - static StringList split(const String &s, const String &pattern); + static StringList split(const String &s, const String &pattern); - private: - class StringListPrivate; - StringListPrivate *d; - }; + private: + class StringListPrivate; + StringListPrivate *d; +}; -} -} +} // namespace TagLib +} // namespace Strawberry_TagLib /*! * \related Strawberry_TagLib::TagLib::StringList diff --git a/3rdparty/taglib/toolkit/tutils.h b/3rdparty/taglib/toolkit/tutils.h index 135897223..2a91d05a8 100644 --- a/3rdparty/taglib/toolkit/tutils.h +++ b/3rdparty/taglib/toolkit/tutils.h @@ -30,215 +30,196 @@ #ifndef DO_NOT_DOCUMENT // tell Doxygen not to document this header -#ifdef HAVE_CONFIG_H -# include -#endif +# ifdef HAVE_CONFIG_H +# include +# endif -#if defined(HAVE_MSC_BYTESWAP) -# include -#elif defined(HAVE_GLIBC_BYTESWAP) -# include -#elif defined(HAVE_MAC_BYTESWAP) -# include -#elif defined(HAVE_OPENBSD_BYTESWAP) -# include -#endif +# if defined(HAVE_MSC_BYTESWAP) +# include +# elif defined(HAVE_GLIBC_BYTESWAP) +# include +# elif defined(HAVE_MAC_BYTESWAP) +# include +# elif defined(HAVE_OPENBSD_BYTESWAP) +# include +# endif -#include -#include -#include -#include +# include +# include +# include +# include namespace Strawberry_TagLib { -namespace TagLib -{ - namespace Utils - { - namespace - { +namespace TagLib { +namespace Utils { +namespace { - /*! +/*! * Reverses the order of bytes in an 16-bit integer. */ - inline unsigned short byteSwap(unsigned short x) - { -#if defined(HAVE_GCC_BYTESWAP) +inline unsigned short byteSwap(unsigned short x) { +# if defined(HAVE_GCC_BYTESWAP) - return __builtin_bswap16(x); + return __builtin_bswap16(x); -#elif defined(HAVE_MSC_BYTESWAP) +# elif defined(HAVE_MSC_BYTESWAP) - return _byteswap_ushort(x); + return _byteswap_ushort(x); -#elif defined(HAVE_GLIBC_BYTESWAP) +# elif defined(HAVE_GLIBC_BYTESWAP) - return __bswap_16(x); + return __bswap_16(x); -#elif defined(HAVE_MAC_BYTESWAP) +# elif defined(HAVE_MAC_BYTESWAP) - return OSSwapInt16(x); + return OSSwapInt16(x); -#elif defined(HAVE_OPENBSD_BYTESWAP) +# elif defined(HAVE_OPENBSD_BYTESWAP) - return swap16(x); + return swap16(x); -#else +# else - return ((x >> 8) & 0xff) | ((x & 0xff) << 8); + return ((x >> 8) & 0xff) | ((x & 0xff) << 8); -#endif - } +# endif +} - /*! +/*! * Reverses the order of bytes in an 32-bit integer. */ - inline unsigned int byteSwap(unsigned int x) - { -#if defined(HAVE_GCC_BYTESWAP) +inline unsigned int byteSwap(unsigned int x) { +# if defined(HAVE_GCC_BYTESWAP) - return __builtin_bswap32(x); + return __builtin_bswap32(x); -#elif defined(HAVE_MSC_BYTESWAP) +# elif defined(HAVE_MSC_BYTESWAP) - return _byteswap_ulong(x); + return _byteswap_ulong(x); -#elif defined(HAVE_GLIBC_BYTESWAP) +# elif defined(HAVE_GLIBC_BYTESWAP) - return __bswap_32(x); + return __bswap_32(x); -#elif defined(HAVE_MAC_BYTESWAP) +# elif defined(HAVE_MAC_BYTESWAP) - return OSSwapInt32(x); + return OSSwapInt32(x); -#elif defined(HAVE_OPENBSD_BYTESWAP) +# elif defined(HAVE_OPENBSD_BYTESWAP) - return swap32(x); + return swap32(x); -#else +# else - return ((x & 0xff000000u) >> 24) - | ((x & 0x00ff0000u) >> 8) - | ((x & 0x0000ff00u) << 8) - | ((x & 0x000000ffu) << 24); + return ((x & 0xff000000u) >> 24) | ((x & 0x00ff0000u) >> 8) | ((x & 0x0000ff00u) << 8) | ((x & 0x000000ffu) << 24); -#endif - } +# endif +} - /*! +/*! * Reverses the order of bytes in an 64-bit integer. */ - inline unsigned long long byteSwap(unsigned long long x) - { -#if defined(HAVE_GCC_BYTESWAP) +inline unsigned long long byteSwap(unsigned long long x) { +# if defined(HAVE_GCC_BYTESWAP) - return __builtin_bswap64(x); + return __builtin_bswap64(x); -#elif defined(HAVE_MSC_BYTESWAP) +# elif defined(HAVE_MSC_BYTESWAP) - return _byteswap_uint64(x); + return _byteswap_uint64(x); -#elif defined(HAVE_GLIBC_BYTESWAP) +# elif defined(HAVE_GLIBC_BYTESWAP) - return __bswap_64(x); + return __bswap_64(x); -#elif defined(HAVE_MAC_BYTESWAP) +# elif defined(HAVE_MAC_BYTESWAP) - return OSSwapInt64(x); + return OSSwapInt64(x); -#elif defined(HAVE_OPENBSD_BYTESWAP) +# elif defined(HAVE_OPENBSD_BYTESWAP) - return swap64(x); + return swap64(x); -#else +# else - return ((x & 0xff00000000000000ull) >> 56) - | ((x & 0x00ff000000000000ull) >> 40) - | ((x & 0x0000ff0000000000ull) >> 24) - | ((x & 0x000000ff00000000ull) >> 8) - | ((x & 0x00000000ff000000ull) << 8) - | ((x & 0x0000000000ff0000ull) << 24) - | ((x & 0x000000000000ff00ull) << 40) - | ((x & 0x00000000000000ffull) << 56); + return ((x & 0xff00000000000000ull) >> 56) | ((x & 0x00ff000000000000ull) >> 40) | ((x & 0x0000ff0000000000ull) >> 24) | ((x & 0x000000ff00000000ull) >> 8) | ((x & 0x00000000ff000000ull) << 8) | ((x & 0x0000000000ff0000ull) << 24) | ((x & 0x000000000000ff00ull) << 40) | ((x & 0x00000000000000ffull) << 56); -#endif - } +# endif +} - /*! +/*! * Returns a formatted string just like standard sprintf(), but makes use of * safer functions such as snprintf() if available. */ - inline String formatString(const char *format, ...) - { - // Sufficient buffer size for the current internal uses. - // Consider changing this value when you use this function. +inline String formatString(const char *format, ...) { + // Sufficient buffer size for the current internal uses. + // Consider changing this value when you use this function. - static const size_t BufferSize = 128; + static const size_t BufferSize = 128; - va_list args; - va_start(args, format); + va_list args; + va_start(args, format); - char buf[BufferSize]; - int length; + char buf[BufferSize]; + int length; -#if defined(HAVE_VSNPRINTF) +# if defined(HAVE_VSNPRINTF) - length = vsnprintf(buf, BufferSize, format, args); + length = vsnprintf(buf, BufferSize, format, args); -#elif defined(HAVE_VSPRINTF_S) +# elif defined(HAVE_VSPRINTF_S) - length = vsprintf_s(buf, format, args); + length = vsprintf_s(buf, format, args); -#else +# else - // The last resort. May cause a buffer overflow. + // The last resort. May cause a buffer overflow. - length = vsprintf(buf, format, args); - if(length >= (int)BufferSize) { - debug("Utils::formatString() - Buffer overflow! Returning an empty string."); - length = -1; - } + length = vsprintf(buf, format, args); + if (length >= (int)BufferSize) { + debug("Utils::formatString() - Buffer overflow! Returning an empty string."); + length = -1; + } -#endif +# endif - va_end(args); + va_end(args); - if(length > 0) - return String(buf); - else - return String(); - } + if (length > 0) + return String(buf); + else + return String(); +} - /*! +/*! * The types of byte order of the running system. */ - enum ByteOrder - { - //! Little endian systems. - LittleEndian, - //! Big endian systems. - BigEndian - }; +enum ByteOrder { + //! Little endian systems. + LittleEndian, + //! Big endian systems. + BigEndian +}; - /*! +/*! * Returns the byte order of the system. */ - inline ByteOrder systemByteOrder() - { - union { - int i; - char c; - } u; +inline ByteOrder systemByteOrder() { + union { + int i; + char c; + } u; - u.i = 1; - if(u.c == 1) - return LittleEndian; - else - return BigEndian; - } - } - } -} + u.i = 1; + if (u.c == 1) + return LittleEndian; + else + return BigEndian; } +} // namespace +} // namespace Utils +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/toolkit/tzlib.cpp b/3rdparty/taglib/toolkit/tzlib.cpp index b65b6b08b..88bebcea7 100644 --- a/3rdparty/taglib/toolkit/tzlib.cpp +++ b/3rdparty/taglib/toolkit/tzlib.cpp @@ -24,21 +24,20 @@ ***************************************************************************/ #ifdef HAVE_CONFIG_H -# include +# include #endif #ifdef HAVE_ZLIB -# include -# include -# include +# include +# include +# include #endif #include "tzlib.h" using namespace Strawberry_TagLib::TagLib; -bool zlib::isAvailable() -{ +bool zlib::isAvailable() { #ifdef HAVE_ZLIB return true; @@ -50,13 +49,12 @@ bool zlib::isAvailable() #endif } -ByteVector zlib::decompress(const ByteVector &data) -{ +ByteVector zlib::decompress(const ByteVector &data) { #ifdef HAVE_ZLIB z_stream stream = {}; - if(inflateInit(&stream) != Z_OK) { + if (inflateInit(&stream) != Z_OK) { debug("zlib::decompress() - Failed to initizlize zlib."); return ByteVector(); } @@ -64,7 +62,7 @@ ByteVector zlib::decompress(const ByteVector &data) ByteVector inData = data; stream.avail_in = static_cast(inData.size()); - stream.next_in = reinterpret_cast(inData.data()); + stream.next_in = reinterpret_cast(inData.data()); const unsigned int chunkSize = 1024; @@ -75,16 +73,15 @@ ByteVector zlib::decompress(const ByteVector &data) outData.resize(outData.size() + chunkSize); stream.avail_out = static_cast(chunkSize); - stream.next_out = reinterpret_cast(outData.data() + offset); + stream.next_out = reinterpret_cast(outData.data() + offset); const int result = inflate(&stream, Z_NO_FLUSH); - if(result == Z_STREAM_ERROR || - result == Z_NEED_DICT || - result == Z_DATA_ERROR || - result == Z_MEM_ERROR) - { - if(result != Z_STREAM_ERROR) + if (result == Z_STREAM_ERROR || + result == Z_NEED_DICT || + result == Z_DATA_ERROR || + result == Z_MEM_ERROR) { + if (result != Z_STREAM_ERROR) inflateEnd(&stream); debug("zlib::decompress() - Error reading compressed stream."); @@ -92,7 +89,7 @@ ByteVector zlib::decompress(const ByteVector &data) } outData.resize(outData.size() - stream.avail_out); - } while(stream.avail_out == 0); + } while (stream.avail_out == 0); inflateEnd(&stream); diff --git a/3rdparty/taglib/toolkit/tzlib.h b/3rdparty/taglib/toolkit/tzlib.h index a378bd201..d90fa2dd3 100644 --- a/3rdparty/taglib/toolkit/tzlib.h +++ b/3rdparty/taglib/toolkit/tzlib.h @@ -35,21 +35,21 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace zlib { +namespace zlib { - /*! +/*! * Returns whether or not zlib is installed and ready to use. */ - bool isAvailable(); +bool isAvailable(); - /*! +/*! * Decompress \a data by zlib. */ - ByteVector decompress(const ByteVector &data); +ByteVector decompress(const ByteVector &data); - } -} -} +} // namespace zlib +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/trueaudio/trueaudiofile.cpp b/3rdparty/taglib/trueaudio/trueaudiofile.cpp index ef47111c6..723e8d314 100644 --- a/3rdparty/taglib/trueaudio/trueaudiofile.cpp +++ b/3rdparty/taglib/trueaudio/trueaudiofile.cpp @@ -42,23 +42,20 @@ using namespace Strawberry_TagLib::TagLib; -namespace -{ - enum { TrueAudioID3v2Index = 0, TrueAudioID3v1Index = 1 }; +namespace { +enum { TrueAudioID3v2Index = 0, + TrueAudioID3v1Index = 1 }; } -class TrueAudio::File::FilePrivate -{ -public: - explicit FilePrivate(const ID3v2::FrameFactory *frameFactory = ID3v2::FrameFactory::instance()) : - ID3v2FrameFactory(frameFactory), - ID3v2Location(-1), - ID3v2OriginalSize(0), - ID3v1Location(-1), - properties(0) {} +class TrueAudio::File::FilePrivate { + public: + explicit FilePrivate(const ID3v2::FrameFactory *frameFactory = ID3v2::FrameFactory::instance()) : ID3v2FrameFactory(frameFactory), + ID3v2Location(-1), + ID3v2OriginalSize(0), + ID3v1Location(-1), + properties(0) {} - ~FilePrivate() - { + ~FilePrivate() { delete properties; } @@ -77,8 +74,7 @@ public: // static members //////////////////////////////////////////////////////////////////////////////// -bool TrueAudio::File::isSupported(IOStream *stream) -{ +bool TrueAudio::File::isSupported(IOStream *stream) { // A TrueAudio file has to start with "TTA". An ID3v2 tag may precede. const ByteVector id = Utils::readHeader(stream, 3, true); @@ -89,98 +85,82 @@ bool TrueAudio::File::isSupported(IOStream *stream) // public members //////////////////////////////////////////////////////////////////////////////// -TrueAudio::File::File(FileName file, bool readProperties, Properties::ReadStyle) : - Strawberry_TagLib::TagLib::File(file), - d(new FilePrivate()) -{ - if(isOpen()) +TrueAudio::File::File(FileName file, bool readProperties, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(file), + d(new FilePrivate()) { + if (isOpen()) read(readProperties); } TrueAudio::File::File(FileName file, ID3v2::FrameFactory *frameFactory, - bool readProperties, Properties::ReadStyle) : - Strawberry_TagLib::TagLib::File(file), - d(new FilePrivate(frameFactory)) -{ - if(isOpen()) + bool readProperties, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(file), + d(new FilePrivate(frameFactory)) { + if (isOpen()) read(readProperties); } -TrueAudio::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) : - Strawberry_TagLib::TagLib::File(stream), - d(new FilePrivate()) -{ - if(isOpen()) +TrueAudio::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(stream), + d(new FilePrivate()) { + if (isOpen()) read(readProperties); } TrueAudio::File::File(IOStream *stream, ID3v2::FrameFactory *frameFactory, - bool readProperties, Properties::ReadStyle) : - Strawberry_TagLib::TagLib::File(stream), - d(new FilePrivate(frameFactory)) -{ - if(isOpen()) + bool readProperties, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(stream), + d(new FilePrivate(frameFactory)) { + if (isOpen()) read(readProperties); } -TrueAudio::File::~File() -{ +TrueAudio::File::~File() { delete d; } -Strawberry_TagLib::TagLib::Tag *TrueAudio::File::tag() const -{ +Strawberry_TagLib::TagLib::Tag *TrueAudio::File::tag() const { return &d->tag; } -PropertyMap TrueAudio::File::properties() const -{ +PropertyMap TrueAudio::File::properties() const { return d->tag.properties(); } -void TrueAudio::File::removeUnsupportedProperties(const StringList &unsupported) -{ +void TrueAudio::File::removeUnsupportedProperties(const StringList &unsupported) { d->tag.removeUnsupportedProperties(unsupported); } -PropertyMap TrueAudio::File::setProperties(const PropertyMap &properties) -{ - if(ID3v1Tag()) +PropertyMap TrueAudio::File::setProperties(const PropertyMap &properties) { + if (ID3v1Tag()) ID3v1Tag()->setProperties(properties); return ID3v2Tag(true)->setProperties(properties); } -TrueAudio::Properties *TrueAudio::File::audioProperties() const -{ +TrueAudio::Properties *TrueAudio::File::audioProperties() const { return d->properties; } -void TrueAudio::File::setID3v2FrameFactory(const ID3v2::FrameFactory *factory) -{ +void TrueAudio::File::setID3v2FrameFactory(const ID3v2::FrameFactory *factory) { d->ID3v2FrameFactory = factory; } -bool TrueAudio::File::save() -{ - if(readOnly()) { +bool TrueAudio::File::save() { + if (readOnly()) { debug("TrueAudio::File::save() -- File is read only."); return false; } // Update ID3v2 tag - if(ID3v2Tag() && !ID3v2Tag()->isEmpty()) { + if (ID3v2Tag() && !ID3v2Tag()->isEmpty()) { // ID3v2 tag is not empty. Update the old one or create a new one. - if(d->ID3v2Location < 0) + if (d->ID3v2Location < 0) d->ID3v2Location = 0; const ByteVector data = ID3v2Tag()->render(); insert(data, d->ID3v2Location, d->ID3v2OriginalSize); - if(d->ID3v1Location >= 0) + if (d->ID3v1Location >= 0) d->ID3v1Location += (static_cast(data.size()) - d->ID3v2OriginalSize); d->ID3v2OriginalSize = data.size(); @@ -189,10 +169,10 @@ bool TrueAudio::File::save() // ID3v2 tag is empty. Remove the old one. - if(d->ID3v2Location >= 0) { + if (d->ID3v2Location >= 0) { removeBlock(d->ID3v2Location, d->ID3v2OriginalSize); - if(d->ID3v1Location >= 0) + if (d->ID3v1Location >= 0) d->ID3v1Location -= d->ID3v2OriginalSize; d->ID3v2Location = -1; @@ -202,11 +182,11 @@ bool TrueAudio::File::save() // Update ID3v1 tag - if(ID3v1Tag() && !ID3v1Tag()->isEmpty()) { + if (ID3v1Tag() && !ID3v1Tag()->isEmpty()) { // ID3v1 tag is not empty. Update the old one or create a new one. - if(d->ID3v1Location >= 0) { + if (d->ID3v1Location >= 0) { seek(d->ID3v1Location); } else { @@ -220,7 +200,7 @@ bool TrueAudio::File::save() // ID3v1 tag is empty. Remove the old one. - if(d->ID3v1Location >= 0) { + if (d->ID3v1Location >= 0) { truncate(d->ID3v1Location); d->ID3v1Location = -1; } @@ -229,35 +209,30 @@ bool TrueAudio::File::save() return true; } -ID3v1::Tag *TrueAudio::File::ID3v1Tag(bool create) -{ +ID3v1::Tag *TrueAudio::File::ID3v1Tag(bool create) { return d->tag.access(TrueAudioID3v1Index, create); } -ID3v2::Tag *TrueAudio::File::ID3v2Tag(bool create) -{ +ID3v2::Tag *TrueAudio::File::ID3v2Tag(bool create) { return d->tag.access(TrueAudioID3v2Index, create); } -void TrueAudio::File::strip(int tags) -{ - if(tags & ID3v1) +void TrueAudio::File::strip(int tags) { + if (tags & ID3v1) d->tag.set(TrueAudioID3v1Index, 0); - if(tags & ID3v2) + if (tags & ID3v2) d->tag.set(TrueAudioID3v2Index, 0); - if(!ID3v1Tag()) + if (!ID3v1Tag()) ID3v2Tag(true); } -bool TrueAudio::File::hasID3v1Tag() const -{ +bool TrueAudio::File::hasID3v1Tag() const { return (d->ID3v1Location >= 0); } -bool TrueAudio::File::hasID3v2Tag() const -{ +bool TrueAudio::File::hasID3v2Tag() const { return (d->ID3v2Location >= 0); } @@ -265,13 +240,12 @@ bool TrueAudio::File::hasID3v2Tag() const // private members //////////////////////////////////////////////////////////////////////////////// -void TrueAudio::File::read(bool readProperties) -{ +void TrueAudio::File::read(bool readProperties) { // Look for an ID3v2 tag d->ID3v2Location = Utils::findID3v2(this); - if(d->ID3v2Location >= 0) { + if (d->ID3v2Location >= 0) { d->tag.set(TrueAudioID3v2Index, new ID3v2::Tag(this, d->ID3v2Location, d->ID3v2FrameFactory)); d->ID3v2OriginalSize = ID3v2Tag()->header()->completeTagSize(); } @@ -280,24 +254,24 @@ void TrueAudio::File::read(bool readProperties) d->ID3v1Location = Utils::findID3v1(this); - if(d->ID3v1Location >= 0) + if (d->ID3v1Location >= 0) d->tag.set(TrueAudioID3v1Index, new ID3v1::Tag(this, d->ID3v1Location)); - if(d->ID3v1Location < 0) + if (d->ID3v1Location < 0) ID3v2Tag(true); // Look for TrueAudio metadata - if(readProperties) { + if (readProperties) { long streamLength; - if(d->ID3v1Location >= 0) + if (d->ID3v1Location >= 0) streamLength = d->ID3v1Location; else streamLength = length(); - if(d->ID3v2Location >= 0) { + if (d->ID3v2Location >= 0) { seek(d->ID3v2Location + d->ID3v2OriginalSize); streamLength -= (d->ID3v2Location + d->ID3v2OriginalSize); } diff --git a/3rdparty/taglib/trueaudio/trueaudiofile.h b/3rdparty/taglib/trueaudio/trueaudiofile.h index 4705d0da7..986e6af6c 100644 --- a/3rdparty/taglib/trueaudio/trueaudiofile.h +++ b/3rdparty/taglib/trueaudio/trueaudiofile.h @@ -36,59 +36,63 @@ namespace Strawberry_TagLib { namespace TagLib { - class Tag; +class Tag; - namespace ID3v2 { class Tag; class FrameFactory; } - namespace ID3v1 { class Tag; } +namespace ID3v2 { +class Tag; +class FrameFactory; +} // namespace ID3v2 +namespace ID3v1 { +class Tag; +} - //! An implementation of TrueAudio metadata +//! An implementation of TrueAudio metadata - /*! +/*! * This is implementation of TrueAudio metadata. * * This supports ID3v1 and ID3v2 tags as well as reading stream * properties from the file. */ - namespace TrueAudio { +namespace TrueAudio { - //! An implementation of TagLib::File with TrueAudio specific methods +//! An implementation of TagLib::File with TrueAudio specific methods - /*! +/*! * This implements and provides an interface for TrueAudio files to the * TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing * the abstract TagLib::File API as well as providing some additional * information specific to TrueAudio files. */ - class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File - { - public: - /*! +class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File { + public: + /*! * This set of flags is used for various operations and is suitable for * being OR-ed together. */ - enum TagTypes { - //! Empty set. Matches no tag types. - NoTags = 0x0000, - //! Matches ID3v1 tags. - ID3v1 = 0x0001, - //! Matches ID3v2 tags. - ID3v2 = 0x0002, - //! Matches all tag types. - AllTags = 0xffff - }; + enum TagTypes { + //! Empty set. Matches no tag types. + NoTags = 0x0000, + //! Matches ID3v1 tags. + ID3v1 = 0x0001, + //! Matches ID3v2 tags. + ID3v2 = 0x0002, + //! Matches all tag types. + AllTags = 0xffff + }; - /*! + /*! * Constructs a TrueAudio file from \a file. If \a readProperties is true * the file's audio properties will also be read. * * \note In the current implementation, \a propertiesStyle is ignored. */ - File(FileName file, bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(FileName file, bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Constructs a TrueAudio file from \a file. If \a readProperties is true * the file's audio properties will also be read. * @@ -97,11 +101,11 @@ namespace TagLib { * * \note In the current implementation, \a propertiesStyle is ignored. */ - File(FileName file, ID3v2::FrameFactory *frameFactory, - bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(FileName file, ID3v2::FrameFactory *frameFactory, + bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Constructs a TrueAudio file from \a stream. If \a readProperties is true * the file's audio properties will also be read. * @@ -110,10 +114,10 @@ namespace TagLib { * * \note In the current implementation, \a propertiesStyle is ignored. */ - File(IOStream *stream, bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(IOStream *stream, bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Constructs a TrueAudio file from \a stream. If \a readProperties is true * the file's audio properties will also be read. * @@ -125,56 +129,56 @@ namespace TagLib { * * \note In the current implementation, \a propertiesStyle is ignored. */ - File(IOStream *stream, ID3v2::FrameFactory *frameFactory, - bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(IOStream *stream, ID3v2::FrameFactory *frameFactory, + bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Destroys this instance of the File. */ - virtual ~File(); + virtual ~File(); - /*! + /*! * Returns the Tag for this file. */ - virtual Strawberry_TagLib::TagLib::Tag *tag() const; + virtual Strawberry_TagLib::TagLib::Tag *tag() const; - /*! + /*! * Implements the unified property interface -- export function. * If the file contains both ID3v1 and v2 tags, only ID3v2 will be * converted to the PropertyMap. */ - PropertyMap properties() const; + PropertyMap properties() const; - /*! + /*! * Implements the unified property interface -- import function. * Creates in ID3v2 tag if necessary. If an ID3v1 tag exists, it will * be updated as well, within the limitations of ID3v1. */ - PropertyMap setProperties(const PropertyMap &); + PropertyMap setProperties(const PropertyMap &); - void removeUnsupportedProperties(const StringList &properties); + void removeUnsupportedProperties(const StringList &properties); - /*! + /*! * Returns the TrueAudio::Properties for this file. If no audio properties * were read then this will return a null pointer. */ - virtual Properties *audioProperties() const; + virtual Properties *audioProperties() const; - /*! + /*! * Set the ID3v2::FrameFactory to something other than the default. * * \see ID3v2FrameFactory * \deprecated This value should be passed in via the constructor */ - TAGLIB_DEPRECATED void setID3v2FrameFactory(const ID3v2::FrameFactory *factory); + TAGLIB_DEPRECATED void setID3v2FrameFactory(const ID3v2::FrameFactory *factory); - /*! + /*! * Saves the file. */ - virtual bool save(); + virtual bool save(); - /*! + /*! * Returns a pointer to the ID3v1 tag of the file. * * If \a create is false (the default) this may return a null pointer @@ -191,9 +195,9 @@ namespace TagLib { * * \see hasID3v1Tag() */ - ID3v1::Tag *ID3v1Tag(bool create = false); + ID3v1::Tag *ID3v1Tag(bool create = false); - /*! + /*! * Returns a pointer to the ID3v2 tag of the file. * * If \a create is false (the default) this may return a null pointer @@ -210,9 +214,9 @@ namespace TagLib { * * \see hasID3v2Tag() */ - ID3v2::Tag *ID3v2Tag(bool create = false); + ID3v2::Tag *ID3v2Tag(bool create = false); - /*! + /*! * This will remove the tags that match the OR-ed together TagTypes from the * file. By default it removes all tags. * @@ -220,42 +224,42 @@ namespace TagLib { * as their memory will be freed. * \note In order to make the removal permanent save() still needs to be called */ - void strip(int tags = AllTags); + void strip(int tags = AllTags); - /*! + /*! * Returns whether or not the file on disk actually has an ID3v1 tag. * * \see ID3v1Tag() */ - bool hasID3v1Tag() const; + bool hasID3v1Tag() const; - /*! + /*! * Returns whether or not the file on disk actually has an ID3v2 tag. * * \see ID3v2Tag() */ - bool hasID3v2Tag() const; + bool hasID3v2Tag() const; - /*! + /*! * Returns whether or not the given \a stream can be opened as a TrueAudio * file. * * \note This method is designed to do a quick check. The result may * not necessarily be correct. */ - static bool isSupported(IOStream *stream); + static bool isSupported(IOStream *stream); - private: - File(const File &); - File &operator=(const File &); + private: + File(const File &); + File &operator=(const File &); - void read(bool readProperties); + void read(bool readProperties); - class FilePrivate; - FilePrivate *d; - }; - } -} -} + class FilePrivate; + FilePrivate *d; +}; +} // namespace TrueAudio +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/trueaudio/trueaudioproperties.cpp b/3rdparty/taglib/trueaudio/trueaudioproperties.cpp index 7ddbabb87..ce972a0ce 100644 --- a/3rdparty/taglib/trueaudio/trueaudioproperties.cpp +++ b/3rdparty/taglib/trueaudio/trueaudioproperties.cpp @@ -36,17 +36,15 @@ using namespace Strawberry_TagLib::TagLib; -class TrueAudio::Properties::PropertiesPrivate -{ -public: - PropertiesPrivate() : - version(0), - length(0), - bitrate(0), - sampleRate(0), - channels(0), - bitsPerSample(0), - sampleFrames(0) {} +class TrueAudio::Properties::PropertiesPrivate { + public: + PropertiesPrivate() : version(0), + length(0), + bitrate(0), + sampleRate(0), + channels(0), + bitsPerSample(0), + sampleFrames(0) {} int version; int length; @@ -61,60 +59,48 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -TrueAudio::Properties::Properties(const ByteVector &data, long streamLength, ReadStyle style) : - AudioProperties(style), - d(new PropertiesPrivate()) -{ +TrueAudio::Properties::Properties(const ByteVector &data, long streamLength, ReadStyle style) : AudioProperties(style), + d(new PropertiesPrivate()) { read(data, streamLength); } -TrueAudio::Properties::~Properties() -{ +TrueAudio::Properties::~Properties() { delete d; } -int TrueAudio::Properties::length() const -{ +int TrueAudio::Properties::length() const { return lengthInSeconds(); } -int TrueAudio::Properties::lengthInSeconds() const -{ +int TrueAudio::Properties::lengthInSeconds() const { return d->length / 1000; } -int TrueAudio::Properties::lengthInMilliseconds() const -{ +int TrueAudio::Properties::lengthInMilliseconds() const { return d->length; } -int TrueAudio::Properties::bitrate() const -{ +int TrueAudio::Properties::bitrate() const { return d->bitrate; } -int TrueAudio::Properties::sampleRate() const -{ +int TrueAudio::Properties::sampleRate() const { return d->sampleRate; } -int TrueAudio::Properties::bitsPerSample() const -{ +int TrueAudio::Properties::bitsPerSample() const { return d->bitsPerSample; } -int TrueAudio::Properties::channels() const -{ +int TrueAudio::Properties::channels() const { return d->channels; } -unsigned int TrueAudio::Properties::sampleFrames() const -{ +unsigned int TrueAudio::Properties::sampleFrames() const { return d->sampleFrames; } -int TrueAudio::Properties::ttaVersion() const -{ +int TrueAudio::Properties::ttaVersion() const { return d->version; } @@ -122,14 +108,13 @@ int TrueAudio::Properties::ttaVersion() const // private members //////////////////////////////////////////////////////////////////////////////// -void TrueAudio::Properties::read(const ByteVector &data, long streamLength) -{ - if(data.size() < 4) { +void TrueAudio::Properties::read(const ByteVector &data, long streamLength) { + if (data.size() < 4) { debug("TrueAudio::Properties::read() -- data is too short."); return; } - if(!data.startsWith("TTA")) { + if (!data.startsWith("TTA")) { debug("TrueAudio::Properties::read() -- invalid header signature."); return; } @@ -141,8 +126,8 @@ void TrueAudio::Properties::read(const ByteVector &data, long streamLength) // According to http://en.true-audio.com/TTA_Lossless_Audio_Codec_-_Format_Description // TTA2 headers are in development, and have a different format - if(1 == d->version) { - if(data.size() < 18) { + if (1 == d->version) { + if (data.size() < 18) { debug("TrueAudio::Properties::read() -- data is too short."); return; } @@ -161,9 +146,9 @@ void TrueAudio::Properties::read(const ByteVector &data, long streamLength) d->sampleFrames = data.toUInt(pos, false); - if(d->sampleFrames > 0 && d->sampleRate > 0) { + if (d->sampleFrames > 0 && d->sampleRate > 0) { const double length = d->sampleFrames * 1000.0 / d->sampleRate; - d->length = static_cast(length + 0.5); + d->length = static_cast(length + 0.5); d->bitrate = static_cast(streamLength * 8.0 / length + 0.5); } } diff --git a/3rdparty/taglib/trueaudio/trueaudioproperties.h b/3rdparty/taglib/trueaudio/trueaudioproperties.h index 4e7705e37..a6ae07dfc 100644 --- a/3rdparty/taglib/trueaudio/trueaudioproperties.h +++ b/3rdparty/taglib/trueaudio/trueaudioproperties.h @@ -35,34 +35,33 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace TrueAudio { +namespace TrueAudio { - class File; +class File; - static const unsigned int HeaderSize = 18; +static const unsigned int HeaderSize = 18; - //! An implementation of audio property reading for TrueAudio +//! An implementation of audio property reading for TrueAudio - /*! +/*! * This reads the data from an TrueAudio stream found in the AudioProperties * API. */ - class TAGLIB_EXPORT Properties : public AudioProperties - { - public: - /*! +class TAGLIB_EXPORT Properties : public AudioProperties { + public: + /*! * Create an instance of TrueAudio::Properties with the data read from the * ByteVector \a data. */ - Properties(const ByteVector &data, long streamLength, ReadStyle style = Average); + Properties(const ByteVector &data, long streamLength, ReadStyle style = Average); - /*! + /*! * Destroys this TrueAudio::Properties instance. */ - virtual ~Properties(); + virtual ~Properties(); - /*! + /*! * Returns the length of the file in seconds. The length is rounded down to * the nearest whole second. * @@ -70,66 +69,66 @@ namespace TagLib { * * \deprecated */ - virtual int length() const; + virtual int length() const; - /*! + /*! * Returns the length of the file in seconds. The length is rounded down to * the nearest whole second. * * \see lengthInMilliseconds() */ - // BIC: make virtual - int lengthInSeconds() const; + // BIC: make virtual + int lengthInSeconds() const; - /*! + /*! * Returns the length of the file in milliseconds. * * \see lengthInSeconds() */ - // BIC: make virtual - int lengthInMilliseconds() const; + // BIC: make virtual + int lengthInMilliseconds() const; - /*! + /*! * Returns the average bit rate of the file in kb/s. */ - virtual int bitrate() const; + virtual int bitrate() const; - /*! + /*! * Returns the sample rate in Hz. */ - virtual int sampleRate() const; + virtual int sampleRate() const; - /*! + /*! * Returns the number of audio channels. */ - virtual int channels() const; + virtual int channels() const; - /*! + /*! * Returns the number of bits per audio sample. */ - int bitsPerSample() const; + int bitsPerSample() const; - /*! + /*! * Returns the total number of sample frames */ - unsigned int sampleFrames() const; + unsigned int sampleFrames() const; - /*! + /*! * Returns the major version number. */ - int ttaVersion() const; + int ttaVersion() const; - private: - Properties(const Properties &); - Properties &operator=(const Properties &); + private: + Properties(const Properties &); + Properties &operator=(const Properties &); - void read(const ByteVector &data, long streamLength); + void read(const ByteVector &data, long streamLength); - class PropertiesPrivate; - PropertiesPrivate *d; - }; - } -} -} + class PropertiesPrivate; + PropertiesPrivate *d; +}; +} // namespace TrueAudio +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/wavpack/wavpackfile.cpp b/3rdparty/taglib/wavpack/wavpackfile.cpp index e7678b5f8..91db5f8bc 100644 --- a/3rdparty/taglib/wavpack/wavpackfile.cpp +++ b/3rdparty/taglib/wavpack/wavpackfile.cpp @@ -42,22 +42,19 @@ using namespace Strawberry_TagLib::TagLib; -namespace -{ - enum { WavAPEIndex, WavID3v1Index }; +namespace { +enum { WavAPEIndex, + WavID3v1Index }; } -class WavPack::File::FilePrivate -{ -public: - FilePrivate() : - APELocation(-1), - APESize(0), - ID3v1Location(-1), - properties(0) {} +class WavPack::File::FilePrivate { + public: + FilePrivate() : APELocation(-1), + APESize(0), + ID3v1Location(-1), + properties(0) {} - ~FilePrivate() - { + ~FilePrivate() { delete properties; } @@ -75,8 +72,7 @@ public: // static members //////////////////////////////////////////////////////////////////////////////// -bool WavPack::File::isSupported(IOStream *stream) -{ +bool WavPack::File::isSupported(IOStream *stream) { // A WavPack file has to start with "wvpk". const ByteVector id = Utils::readHeader(stream, 4, false); @@ -87,69 +83,58 @@ bool WavPack::File::isSupported(IOStream *stream) // public members //////////////////////////////////////////////////////////////////////////////// -WavPack::File::File(FileName file, bool readProperties, Properties::ReadStyle) : - Strawberry_TagLib::TagLib::File(file), - d(new FilePrivate()) -{ - if(isOpen()) +WavPack::File::File(FileName file, bool readProperties, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(file), + d(new FilePrivate()) { + if (isOpen()) read(readProperties); } -WavPack::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) : - Strawberry_TagLib::TagLib::File(stream), - d(new FilePrivate()) -{ - if(isOpen()) +WavPack::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(stream), + d(new FilePrivate()) { + if (isOpen()) read(readProperties); } -WavPack::File::~File() -{ +WavPack::File::~File() { delete d; } -Strawberry_TagLib::TagLib::Tag *WavPack::File::tag() const -{ +Strawberry_TagLib::TagLib::Tag *WavPack::File::tag() const { return &d->tag; } -PropertyMap WavPack::File::properties() const -{ +PropertyMap WavPack::File::properties() const { return d->tag.properties(); } -void WavPack::File::removeUnsupportedProperties(const StringList &unsupported) -{ +void WavPack::File::removeUnsupportedProperties(const StringList &unsupported) { d->tag.removeUnsupportedProperties(unsupported); } -PropertyMap WavPack::File::setProperties(const PropertyMap &properties) -{ - if(ID3v1Tag()) +PropertyMap WavPack::File::setProperties(const PropertyMap &properties) { + if (ID3v1Tag()) ID3v1Tag()->setProperties(properties); return APETag(true)->setProperties(properties); } -WavPack::Properties *WavPack::File::audioProperties() const -{ +WavPack::Properties *WavPack::File::audioProperties() const { return d->properties; } -bool WavPack::File::save() -{ - if(readOnly()) { +bool WavPack::File::save() { + if (readOnly()) { debug("WavPack::File::save() -- File is read only."); return false; } // Update ID3v1 tag - if(ID3v1Tag() && !ID3v1Tag()->isEmpty()) { + if (ID3v1Tag() && !ID3v1Tag()->isEmpty()) { // ID3v1 tag is not empty. Update the old one or create a new one. - if(d->ID3v1Location >= 0) { + if (d->ID3v1Location >= 0) { seek(d->ID3v1Location); } else { @@ -163,7 +148,7 @@ bool WavPack::File::save() // ID3v1 tag is empty. Remove the old one. - if(d->ID3v1Location >= 0) { + if (d->ID3v1Location >= 0) { truncate(d->ID3v1Location); d->ID3v1Location = -1; } @@ -171,12 +156,12 @@ bool WavPack::File::save() // Update APE tag - if(APETag() && !APETag()->isEmpty()) { + if (APETag() && !APETag()->isEmpty()) { // APE tag is not empty. Update the old one or create a new one. - if(d->APELocation < 0) { - if(d->ID3v1Location >= 0) + if (d->APELocation < 0) { + if (d->ID3v1Location >= 0) d->APELocation = d->ID3v1Location; else d->APELocation = length(); @@ -185,7 +170,7 @@ bool WavPack::File::save() const ByteVector data = APETag()->render(); insert(data, d->APELocation, d->APESize); - if(d->ID3v1Location >= 0) + if (d->ID3v1Location >= 0) d->ID3v1Location += (static_cast(data.size()) - d->APESize); d->APESize = data.size(); @@ -194,10 +179,10 @@ bool WavPack::File::save() // APE tag is empty. Remove the old one. - if(d->APELocation >= 0) { + if (d->APELocation >= 0) { removeBlock(d->APELocation, d->APESize); - if(d->ID3v1Location >= 0) + if (d->ID3v1Location >= 0) d->ID3v1Location -= d->APESize; d->APELocation = -1; @@ -208,35 +193,30 @@ bool WavPack::File::save() return true; } -ID3v1::Tag *WavPack::File::ID3v1Tag(bool create) -{ +ID3v1::Tag *WavPack::File::ID3v1Tag(bool create) { return d->tag.access(WavID3v1Index, create); } -APE::Tag *WavPack::File::APETag(bool create) -{ +APE::Tag *WavPack::File::APETag(bool create) { return d->tag.access(WavAPEIndex, create); } -void WavPack::File::strip(int tags) -{ - if(tags & ID3v1) +void WavPack::File::strip(int tags) { + if (tags & ID3v1) d->tag.set(WavID3v1Index, 0); - if(tags & APE) + if (tags & APE) d->tag.set(WavAPEIndex, 0); - if(!ID3v1Tag()) + if (!ID3v1Tag()) APETag(true); } -bool WavPack::File::hasID3v1Tag() const -{ +bool WavPack::File::hasID3v1Tag() const { return (d->ID3v1Location >= 0); } -bool WavPack::File::hasAPETag() const -{ +bool WavPack::File::hasAPETag() const { return (d->APELocation >= 0); } @@ -244,37 +224,36 @@ bool WavPack::File::hasAPETag() const // private members //////////////////////////////////////////////////////////////////////////////// -void WavPack::File::read(bool readProperties) -{ +void WavPack::File::read(bool readProperties) { // Look for an ID3v1 tag d->ID3v1Location = Utils::findID3v1(this); - if(d->ID3v1Location >= 0) + if (d->ID3v1Location >= 0) d->tag.set(WavID3v1Index, new ID3v1::Tag(this, d->ID3v1Location)); // Look for an APE tag d->APELocation = Utils::findAPE(this, d->ID3v1Location); - if(d->APELocation >= 0) { + if (d->APELocation >= 0) { d->tag.set(WavAPEIndex, new APE::Tag(this, d->APELocation)); d->APESize = APETag()->footer()->completeTagSize(); d->APELocation = d->APELocation + APE::Footer::size() - d->APESize; } - if(d->ID3v1Location >= 0) + if (d->ID3v1Location >= 0) APETag(true); // Look for WavPack audio properties - if(readProperties) { + if (readProperties) { long streamLength; - if(d->APELocation >= 0) + if (d->APELocation >= 0) streamLength = d->APELocation; - else if(d->ID3v1Location >= 0) + else if (d->ID3v1Location >= 0) streamLength = d->ID3v1Location; else streamLength = length(); diff --git a/3rdparty/taglib/wavpack/wavpackfile.h b/3rdparty/taglib/wavpack/wavpackfile.h index a9c20e643..773688b40 100644 --- a/3rdparty/taglib/wavpack/wavpackfile.h +++ b/3rdparty/taglib/wavpack/wavpackfile.h @@ -37,58 +37,61 @@ namespace Strawberry_TagLib { namespace TagLib { - class Tag; +class Tag; - namespace ID3v1 { class Tag; } - namespace APE { class Tag; } +namespace ID3v1 { +class Tag; +} +namespace APE { +class Tag; +} - //! An implementation of WavPack metadata +//! An implementation of WavPack metadata - /*! +/*! * This is implementation of WavPack metadata. * * This supports ID3v1 and APE (v1 and v2) style comments as well as reading stream * properties from the file. */ - namespace WavPack { +namespace WavPack { - //! An implementation of Strawberry_TagLib::TagLib::File with WavPack specific methods +//! An implementation of Strawberry_TagLib::TagLib::File with WavPack specific methods - /*! +/*! * This implements and provides an interface for WavPack files to the * Strawberry_TagLib::TagLib::Tag and Strawberry_TagLib::TagLib::AudioProperties interfaces by way of implementing * the abstract Strawberry_TagLib::TagLib::File API as well as providing some additional * information specific to WavPack files. */ - class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File - { - public: - /*! +class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File { + public: + /*! * This set of flags is used for various operations and is suitable for * being OR-ed together. */ - enum TagTypes { - //! Empty set. Matches no tag types. - NoTags = 0x0000, - //! Matches ID3v1 tags. - ID3v1 = 0x0001, - //! Matches APE tags. - APE = 0x0002, - //! Matches all tag types. - AllTags = 0xffff - }; + enum TagTypes { + //! Empty set. Matches no tag types. + NoTags = 0x0000, + //! Matches ID3v1 tags. + ID3v1 = 0x0001, + //! Matches APE tags. + APE = 0x0002, + //! Matches all tag types. + AllTags = 0xffff + }; - /*! + /*! * Constructs a WavPack file from \a file. If \a readProperties is true the * file's audio properties will also be read using \a propertiesStyle. If * false, \a propertiesStyle is ignored */ - File(FileName file, bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(FileName file, bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Constructs an WavPack file from \a file. If \a readProperties is true the * file's audio properties will also be read using \a propertiesStyle. If * false, \a propertiesStyle is ignored. @@ -96,50 +99,50 @@ namespace TagLib { * \note TagLib will *not* take ownership of the stream, the caller is * responsible for deleting it after the File object. */ - File(IOStream *stream, bool readProperties = true, - Properties::ReadStyle propertiesStyle = Properties::Average); + File(IOStream *stream, bool readProperties = true, + Properties::ReadStyle propertiesStyle = Properties::Average); - /*! + /*! * Destroys this instance of the File. */ - virtual ~File(); + virtual ~File(); - /*! + /*! * Returns the Tag for this file. This will be an APE tag, an ID3v1 tag * or a combination of the two. */ - virtual Strawberry_TagLib::TagLib::Tag *tag() const; + virtual Strawberry_TagLib::TagLib::Tag *tag() const; - /*! + /*! * Implements the unified property interface -- export function. * If the file contains both an APE and an ID3v1 tag, only APE * will be converted to the PropertyMap. */ - PropertyMap properties() const; + PropertyMap properties() const; - void removeUnsupportedProperties(const StringList &properties); + void removeUnsupportedProperties(const StringList &properties); - /*! + /*! * Implements the unified property interface -- import function. * Creates an APE tag if it does not exists and calls setProperties() on * that. Any existing ID3v1 tag will be updated as well. */ - PropertyMap setProperties(const PropertyMap&); + PropertyMap setProperties(const PropertyMap &); - /*! + /*! * Returns the MPC::Properties for this file. If no audio properties * were read then this will return a null pointer. */ - virtual Properties *audioProperties() const; + virtual Properties *audioProperties() const; - /*! + /*! * Saves the file. * * This returns true if the save was successful. */ - virtual bool save(); + virtual bool save(); - /*! + /*! * Returns a pointer to the ID3v1 tag of the file. * * If \a create is false (the default) this may return a null pointer @@ -156,9 +159,9 @@ namespace TagLib { * * \see hasID3v1Tag() */ - ID3v1::Tag *ID3v1Tag(bool create = false); + ID3v1::Tag *ID3v1Tag(bool create = false); - /*! + /*! * Returns a pointer to the APE tag of the file. * * If \a create is false (the default) this may return a null pointer @@ -175,9 +178,9 @@ namespace TagLib { * * \see hasAPETag() */ - APE::Tag *APETag(bool create = false); + APE::Tag *APETag(bool create = false); - /*! + /*! * This will remove the tags that match the OR-ed together TagTypes from the * file. By default it removes all tags. * @@ -185,41 +188,41 @@ namespace TagLib { * as their memory will be freed. * \note In order to make the removal permanent save() still needs to be called */ - void strip(int tags = AllTags); + void strip(int tags = AllTags); - /*! + /*! * Returns whether or not the file on disk actually has an ID3v1 tag. * * \see ID3v1Tag() */ - bool hasID3v1Tag() const; + bool hasID3v1Tag() const; - /*! + /*! * Returns whether or not the file on disk actually has an APE tag. * * \see APETag() */ - bool hasAPETag() const; + bool hasAPETag() const; - /*! + /*! * Check if the given \a stream can be opened as a WavPack file. * * \note This method is designed to do a quick check. The result may * not necessarily be correct. */ - static bool isSupported(IOStream *stream); + static bool isSupported(IOStream *stream); - private: - File(const File &); - File &operator=(const File &); + private: + File(const File &); + File &operator=(const File &); - void read(bool readProperties); + void read(bool readProperties); - class FilePrivate; - FilePrivate *d; - }; - } -} -} + class FilePrivate; + FilePrivate *d; +}; +} // namespace WavPack +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/wavpack/wavpackproperties.cpp b/3rdparty/taglib/wavpack/wavpackproperties.cpp index 6cc31a708..7ec87b2ca 100644 --- a/3rdparty/taglib/wavpack/wavpackproperties.cpp +++ b/3rdparty/taglib/wavpack/wavpackproperties.cpp @@ -38,18 +38,16 @@ using namespace Strawberry_TagLib::TagLib; -class WavPack::Properties::PropertiesPrivate -{ -public: - PropertiesPrivate() : - length(0), - bitrate(0), - sampleRate(0), - channels(0), - version(0), - bitsPerSample(0), - lossless(false), - sampleFrames(0) {} +class WavPack::Properties::PropertiesPrivate { + public: + PropertiesPrivate() : length(0), + bitrate(0), + sampleRate(0), + channels(0), + version(0), + bitsPerSample(0), + lossless(false), + sampleFrames(0) {} int length; int bitrate; @@ -65,72 +63,57 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -WavPack::Properties::Properties(const ByteVector &, long, ReadStyle style) : - AudioProperties(style), - d(new PropertiesPrivate()) -{ +WavPack::Properties::Properties(const ByteVector &, long, ReadStyle style) : AudioProperties(style), + d(new PropertiesPrivate()) { debug("WavPack::Properties::Properties() -- This constructor is no longer used."); } -WavPack::Properties::Properties(File *file, long streamLength, ReadStyle style) : - AudioProperties(style), - d(new PropertiesPrivate()) -{ +WavPack::Properties::Properties(File *file, long streamLength, ReadStyle style) : AudioProperties(style), + d(new PropertiesPrivate()) { read(file, streamLength); } -WavPack::Properties::~Properties() -{ +WavPack::Properties::~Properties() { delete d; } -int WavPack::Properties::length() const -{ +int WavPack::Properties::length() const { return lengthInSeconds(); } -int WavPack::Properties::lengthInSeconds() const -{ +int WavPack::Properties::lengthInSeconds() const { return d->length / 1000; } -int WavPack::Properties::lengthInMilliseconds() const -{ +int WavPack::Properties::lengthInMilliseconds() const { return d->length; } -int WavPack::Properties::bitrate() const -{ +int WavPack::Properties::bitrate() const { return d->bitrate; } -int WavPack::Properties::sampleRate() const -{ +int WavPack::Properties::sampleRate() const { return d->sampleRate; } -int WavPack::Properties::channels() const -{ +int WavPack::Properties::channels() const { return d->channels; } -int WavPack::Properties::version() const -{ +int WavPack::Properties::version() const { return d->version; } -int WavPack::Properties::bitsPerSample() const -{ +int WavPack::Properties::bitsPerSample() const { return d->bitsPerSample; } -bool WavPack::Properties::isLossless() const -{ +bool WavPack::Properties::isLossless() const { return d->lossless; } -unsigned int WavPack::Properties::sampleFrames() const -{ +unsigned int WavPack::Properties::sampleFrames() const { return d->sampleFrames; } @@ -138,98 +121,96 @@ unsigned int WavPack::Properties::sampleFrames() const // private members //////////////////////////////////////////////////////////////////////////////// -namespace -{ - const unsigned int sample_rates[] = { - 6000, 8000, 9600, 11025, 12000, 16000, 22050, 24000, - 32000, 44100, 48000, 64000, 88200, 96000, 192000, 0 }; +namespace { +const unsigned int sample_rates[] = { + 6000, 8000, 9600, 11025, 12000, 16000, 22050, 24000, + 32000, 44100, 48000, 64000, 88200, 96000, 192000, 0 +}; } -#define BYTES_STORED 3 -#define MONO_FLAG 4 -#define LOSSLESS_FLAG 8 +#define BYTES_STORED 3 +#define MONO_FLAG 4 +#define LOSSLESS_FLAG 8 -#define SHIFT_LSB 13 -#define SHIFT_MASK (0x1fL << SHIFT_LSB) +#define SHIFT_LSB 13 +#define SHIFT_MASK (0x1fL << SHIFT_LSB) -#define SRATE_LSB 23 -#define SRATE_MASK (0xfL << SRATE_LSB) +#define SRATE_LSB 23 +#define SRATE_MASK (0xfL << SRATE_LSB) #define MIN_STREAM_VERS 0x402 #define MAX_STREAM_VERS 0x410 -#define FINAL_BLOCK 0x1000 +#define FINAL_BLOCK 0x1000 -void WavPack::Properties::read(File *file, long streamLength) -{ +void WavPack::Properties::read(File *file, long streamLength) { long offset = 0; - while(true) { + while (true) { file->seek(offset); const ByteVector data = file->readBlock(32); - if(data.size() < 32) { + if (data.size() < 32) { debug("WavPack::Properties::read() -- data is too short."); break; } - if(!data.startsWith("wvpk")) { + if (!data.startsWith("wvpk")) { debug("WavPack::Properties::read() -- Block header not found."); break; } const unsigned int flags = data.toUInt(24, false); - if(offset == 0) { + if (offset == 0) { d->version = data.toShort(8, false); - if(d->version < MIN_STREAM_VERS || d->version > MAX_STREAM_VERS) + if (d->version < MIN_STREAM_VERS || d->version > MAX_STREAM_VERS) break; d->bitsPerSample = ((flags & BYTES_STORED) + 1) * 8 - ((flags & SHIFT_MASK) >> SHIFT_LSB); - d->sampleRate = sample_rates[(flags & SRATE_MASK) >> SRATE_LSB]; - d->lossless = !(flags & LOSSLESS_FLAG); - d->sampleFrames = data.toUInt(12, false); + d->sampleRate = sample_rates[(flags & SRATE_MASK) >> SRATE_LSB]; + d->lossless = !(flags & LOSSLESS_FLAG); + d->sampleFrames = data.toUInt(12, false); } d->channels += (flags & MONO_FLAG) ? 1 : 2; - if(flags & FINAL_BLOCK) + if (flags & FINAL_BLOCK) break; const unsigned int blockSize = data.toUInt(4, false); offset += blockSize + 8; } - if(d->sampleFrames == ~0u) + if (d->sampleFrames == ~0u) d->sampleFrames = seekFinalIndex(file, streamLength); - if(d->sampleFrames > 0 && d->sampleRate > 0) { + if (d->sampleFrames > 0 && d->sampleRate > 0) { const double length = d->sampleFrames * 1000.0 / d->sampleRate; - d->length = static_cast(length + 0.5); + d->length = static_cast(length + 0.5); d->bitrate = static_cast(streamLength * 8.0 / length + 0.5); } } -unsigned int WavPack::Properties::seekFinalIndex(File *file, long streamLength) -{ +unsigned int WavPack::Properties::seekFinalIndex(File *file, long streamLength) { const long offset = file->rfind("wvpk", streamLength); - if(offset == -1) + if (offset == -1) return 0; file->seek(offset); const ByteVector data = file->readBlock(32); - if(data.size() < 32) + if (data.size() < 32) return 0; const int version = data.toShort(8, false); - if(version < MIN_STREAM_VERS || version > MAX_STREAM_VERS) + if (version < MIN_STREAM_VERS || version > MAX_STREAM_VERS) return 0; const unsigned int flags = data.toUInt(24, false); - if(!(flags & FINAL_BLOCK)) + if (!(flags & FINAL_BLOCK)) return 0; - const unsigned int blockIndex = data.toUInt(16, false); + const unsigned int blockIndex = data.toUInt(16, false); const unsigned int blockSamples = data.toUInt(20, false); return blockIndex + blockSamples; diff --git a/3rdparty/taglib/wavpack/wavpackproperties.h b/3rdparty/taglib/wavpack/wavpackproperties.h index 61073ebaf..a2927328a 100644 --- a/3rdparty/taglib/wavpack/wavpackproperties.h +++ b/3rdparty/taglib/wavpack/wavpackproperties.h @@ -36,43 +36,42 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace WavPack { +namespace WavPack { - class File; +class File; - static const unsigned int HeaderSize = 32; +static const unsigned int HeaderSize = 32; - //! An implementation of audio property reading for WavPack +//! An implementation of audio property reading for WavPack - /*! +/*! * This reads the data from an WavPack stream found in the AudioProperties * API. */ - class TAGLIB_EXPORT Properties : public AudioProperties - { - public: - /*! +class TAGLIB_EXPORT Properties : public AudioProperties { + public: + /*! * Create an instance of WavPack::Properties with the data read from the * ByteVector \a data. * * \deprecated This constructor will be dropped in favor of the one below * in a future version. */ - TAGLIB_DEPRECATED Properties(const ByteVector &data, long streamLength, - ReadStyle style = Average); + TAGLIB_DEPRECATED Properties(const ByteVector &data, long streamLength, + ReadStyle style = Average); - /*! + /*! * Create an instance of WavPack::Properties. */ - Properties(File *file, long streamLength, ReadStyle style = Average); + Properties(File *file, long streamLength, ReadStyle style = Average); - /*! + /*! * Destroys this WavPack::Properties instance. */ - virtual ~Properties(); + virtual ~Properties(); - /*! + /*! * Returns the length of the file in seconds. The length is rounded down to * the nearest whole second. * @@ -80,72 +79,72 @@ namespace TagLib { * * \deprecated */ - TAGLIB_DEPRECATED virtual int length() const; + TAGLIB_DEPRECATED virtual int length() const; - /*! + /*! * Returns the length of the file in seconds. The length is rounded down to * the nearest whole second. * * \see lengthInMilliseconds() */ - // BIC: make virtual - int lengthInSeconds() const; + // BIC: make virtual + int lengthInSeconds() const; - /*! + /*! * Returns the length of the file in milliseconds. * * \see lengthInSeconds() */ - // BIC: make virtual - int lengthInMilliseconds() const; + // BIC: make virtual + int lengthInMilliseconds() const; - /*! + /*! * Returns the average bit rate of the file in kb/s. */ - virtual int bitrate() const; + virtual int bitrate() const; - /*! + /*! * Returns the sample rate in Hz. 0 means unknown or custom. */ - virtual int sampleRate() const; + virtual int sampleRate() const; - /*! + /*! * Returns the number of audio channels. */ - virtual int channels() const; + virtual int channels() const; - /*! + /*! * Returns the number of bits per audio sample. */ - int bitsPerSample() const; + int bitsPerSample() const; - /*! + /*! * Returns whether or not the file is lossless encoded. */ - bool isLossless() const; + bool isLossless() const; - /*! + /*! * Returns the total number of audio samples in file. */ - unsigned int sampleFrames() const; + unsigned int sampleFrames() const; - /*! + /*! * Returns WavPack version. */ - int version() const; + int version() const; - private: - Properties(const Properties &); - Properties &operator=(const Properties &); + private: + Properties(const Properties &); + Properties &operator=(const Properties &); - void read(File *file, long streamLength); - unsigned int seekFinalIndex(File *file, long streamLength); + void read(File *file, long streamLength); + unsigned int seekFinalIndex(File *file, long streamLength); - class PropertiesPrivate; - PropertiesPrivate *d; - }; - } -} -} + class PropertiesPrivate; + PropertiesPrivate *d; +}; +} // namespace WavPack +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/xm/xmfile.cpp b/3rdparty/taglib/xm/xmfile.cpp index e942e75a3..ffef76be3 100644 --- a/3rdparty/taglib/xm/xmfile.cpp +++ b/3rdparty/taglib/xm/xmfile.cpp @@ -64,11 +64,9 @@ using namespace XM; * Maybe if this is useful to other formats these classes can be moved to * their own public files. */ -class Reader -{ -public: - virtual ~Reader() - { +class Reader { + public: + virtual ~Reader() { } /*! @@ -83,55 +81,45 @@ public: virtual unsigned int size() const = 0; }; -class SkipReader : public Reader -{ -public: - explicit SkipReader(unsigned int size) : m_size(size) - { +class SkipReader : public Reader { + public: + explicit SkipReader(unsigned int size) : m_size(size) { } - unsigned int read(Strawberry_TagLib::TagLib::File &file, unsigned int limit) - { + unsigned int read(Strawberry_TagLib::TagLib::File &file, unsigned int limit) { unsigned int count = std::min(m_size, limit); file.seek(count, Strawberry_TagLib::TagLib::File::Current); return count; } - unsigned int size() const - { + unsigned int size() const { return m_size; } -private: + private: unsigned int m_size; }; template -class ValueReader : public Reader -{ -public: - explicit ValueReader(T &_value) : value(_value) - { +class ValueReader : public Reader { + public: + explicit ValueReader(T &_value) : value(_value) { } -protected: + protected: T &value; }; -class StringReader : public ValueReader -{ -public: - StringReader(String &string, unsigned int size) : - ValueReader(string), m_size(size) - { +class StringReader : public ValueReader { + public: + StringReader(String &string, unsigned int size) : ValueReader(string), m_size(size) { } - unsigned int read(Strawberry_TagLib::TagLib::File &file, unsigned int limit) - { + unsigned int read(Strawberry_TagLib::TagLib::File &file, unsigned int limit) { ByteVector data = file.readBlock(std::min(m_size, limit)); unsigned int count = data.size(); - int index = data.find((char) 0); - if(index > -1) { + int index = data.find((char)0); + if (index > -1) { data.resize(index); } data.replace('\xff', ' '); @@ -139,101 +127,83 @@ public: return count; } - unsigned int size() const - { + unsigned int size() const { return m_size; } -private: + private: unsigned int m_size; }; -class ByteReader : public ValueReader -{ -public: +class ByteReader : public ValueReader { + public: explicit ByteReader(unsigned char &_byte) : ValueReader(_byte) {} - unsigned int read(Strawberry_TagLib::TagLib::File &file, unsigned int limit) - { - ByteVector data = file.readBlock(std::min(1U,limit)); - if(data.size() > 0) { + unsigned int read(Strawberry_TagLib::TagLib::File &file, unsigned int limit) { + ByteVector data = file.readBlock(std::min(1U, limit)); + if (data.size() > 0) { value = data[0]; } return data.size(); } - unsigned int size() const - { + unsigned int size() const { return 1; } }; template -class NumberReader : public ValueReader -{ -public: - NumberReader(T &_value, bool _bigEndian) : - ValueReader(_value), bigEndian(_bigEndian) - { +class NumberReader : public ValueReader { + public: + NumberReader(T &_value, bool _bigEndian) : ValueReader(_value), bigEndian(_bigEndian) { } -protected: + protected: bool bigEndian; }; -class U16Reader : public NumberReader -{ -public: +class U16Reader : public NumberReader { + public: U16Reader(unsigned short &_value, bool _bigEndian) - : NumberReader(_value, _bigEndian) {} + : NumberReader(_value, _bigEndian) {} - unsigned int read(Strawberry_TagLib::TagLib::File &file, unsigned int limit) - { - ByteVector data = file.readBlock(std::min(2U,limit)); + unsigned int read(Strawberry_TagLib::TagLib::File &file, unsigned int limit) { + ByteVector data = file.readBlock(std::min(2U, limit)); value = data.toUShort(bigEndian); return data.size(); } - unsigned int size() const - { + unsigned int size() const { return 2; } }; -class U32Reader : public NumberReader -{ -public: - U32Reader(unsigned long &_value, bool _bigEndian = true) : - NumberReader(_value, _bigEndian) - { +class U32Reader : public NumberReader { + public: + U32Reader(unsigned long &_value, bool _bigEndian = true) : NumberReader(_value, _bigEndian) { } - unsigned int read(Strawberry_TagLib::TagLib::File &file, unsigned int limit) - { - ByteVector data = file.readBlock(std::min(4U,limit)); + unsigned int read(Strawberry_TagLib::TagLib::File &file, unsigned int limit) { + ByteVector data = file.readBlock(std::min(4U, limit)); value = data.toUInt(bigEndian); return data.size(); } - unsigned int size() const - { + unsigned int size() const { return 4; } }; -class StructReader : public Reader -{ -public: - StructReader() - { +class StructReader : public Reader { + public: + StructReader() { m_readers.setAutoDelete(true); } /*! * Add a nested reader. This reader takes ownership. */ - StructReader &reader(Reader *reader) - { + StructReader &reader(Reader *reader) { m_readers.append(reader); return *this; } @@ -241,8 +211,7 @@ public: /*! * Don't read anything but skip \a size bytes. */ - StructReader &skip(unsigned int size) - { + StructReader &skip(unsigned int size) { m_readers.append(new SkipReader(size)); return *this; } @@ -250,8 +219,7 @@ public: /*! * Read a string of \a size characters (bytes) into \a string. */ - StructReader &string(String &string, unsigned int size) - { + StructReader &string(String &string, unsigned int size) { m_readers.append(new StringReader(string, size)); return *this; } @@ -259,8 +227,7 @@ public: /*! * Read a byte into \a byte. */ - StructReader &byte(unsigned char &byte) - { + StructReader &byte(unsigned char &byte) { m_readers.append(new ByteReader(byte)); return *this; } @@ -269,8 +236,7 @@ public: * Read a unsigned 16 Bit integer into \a number. The byte order * is controlled by \a bigEndian. */ - StructReader &u16(unsigned short &number, bool bigEndian) - { + StructReader &u16(unsigned short &number, bool bigEndian) { m_readers.append(new U16Reader(number, bigEndian)); return *this; } @@ -278,16 +244,14 @@ public: /*! * Read a unsigned 16 Bit little endian integer into \a number. */ - StructReader &u16L(unsigned short &number) - { + StructReader &u16L(unsigned short &number) { return u16(number, false); } /*! * Read a unsigned 16 Bit big endian integer into \a number. */ - StructReader &u16B(unsigned short &number) - { + StructReader &u16B(unsigned short &number) { return u16(number, true); } @@ -295,8 +259,7 @@ public: * Read a unsigned 32 Bit integer into \a number. The byte order * is controlled by \a bigEndian. */ - StructReader &u32(unsigned long &number, bool bigEndian) - { + StructReader &u32(unsigned long &number, bool bigEndian) { m_readers.append(new U32Reader(number, bigEndian)); return *this; } @@ -304,103 +267,89 @@ public: /*! * Read a unsigned 32 Bit little endian integer into \a number. */ - StructReader &u32L(unsigned long &number) - { + StructReader &u32L(unsigned long &number) { return u32(number, false); } /*! * Read a unsigned 32 Bit big endian integer into \a number. */ - StructReader &u32B(unsigned long &number) - { + StructReader &u32B(unsigned long &number) { return u32(number, true); } - unsigned int size() const - { + unsigned int size() const { unsigned int size = 0; - for(List::ConstIterator i = m_readers.begin(); - i != m_readers.end(); ++ i) { + for (List::ConstIterator i = m_readers.begin(); + i != m_readers.end(); + ++i) { size += (*i)->size(); } return size; } - unsigned int read(Strawberry_TagLib::TagLib::File &file, unsigned int limit) - { + unsigned int read(Strawberry_TagLib::TagLib::File &file, unsigned int limit) { unsigned int sumcount = 0; - for(List::ConstIterator i = m_readers.begin(); - limit > 0 && i != m_readers.end(); ++ i) { + for (List::ConstIterator i = m_readers.begin(); + limit > 0 && i != m_readers.end(); + ++i) { unsigned int count = (*i)->read(file, limit); - limit -= count; + limit -= count; sumcount += count; } return sumcount; } -private: - List m_readers; + private: + List m_readers; }; -class XM::File::FilePrivate -{ -public: +class XM::File::FilePrivate { + public: explicit FilePrivate(AudioProperties::ReadStyle propertiesStyle) - : tag(), properties(propertiesStyle) - { + : tag(), properties(propertiesStyle) { } - Mod::Tag tag; + Mod::Tag tag; XM::Properties properties; }; XM::File::File(FileName file, bool readProperties, - AudioProperties::ReadStyle propertiesStyle) : - Mod::FileBase(file), - d(new FilePrivate(propertiesStyle)) -{ - if(isOpen()) + AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(file), + d(new FilePrivate(propertiesStyle)) { + if (isOpen()) read(readProperties); } XM::File::File(IOStream *stream, bool readProperties, - AudioProperties::ReadStyle propertiesStyle) : - Mod::FileBase(stream), - d(new FilePrivate(propertiesStyle)) -{ - if(isOpen()) + AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(stream), + d(new FilePrivate(propertiesStyle)) { + if (isOpen()) read(readProperties); } -XM::File::~File() -{ +XM::File::~File() { delete d; } -Mod::Tag *XM::File::tag() const -{ +Mod::Tag *XM::File::tag() const { return &d->tag; } -PropertyMap XM::File::properties() const -{ +PropertyMap XM::File::properties() const { return d->tag.properties(); } -PropertyMap XM::File::setProperties(const PropertyMap &properties) -{ +PropertyMap XM::File::setProperties(const PropertyMap &properties) { return d->tag.setProperties(properties); } -XM::Properties *XM::File::audioProperties() const -{ +XM::Properties *XM::File::audioProperties() const { return &d->properties; } -bool XM::File::save() -{ - if(readOnly()) { +bool XM::File::save() { + if (readOnly()) { debug("XM::File::save() - Cannot save to a read only file."); return false; } @@ -413,22 +362,22 @@ bool XM::File::save() seek(60); unsigned long headerSize = 0; - if(!readU32L(headerSize)) + if (!readU32L(headerSize)) return false; seek(70); unsigned short patternCount = 0; unsigned short instrumentCount = 0; - if(!readU16L(patternCount) || !readU16L(instrumentCount)) + if (!readU16L(patternCount) || !readU16L(instrumentCount)) return false; - long pos = 60 + headerSize; // should be long long in taglib2. + long pos = 60 + headerSize; // should be long long in taglib2. // need to read patterns again in order to seek to the instruments: - for(unsigned short i = 0; i < patternCount; ++ i) { + for (unsigned short i = 0; i < patternCount; ++i) { seek(pos); unsigned long patternHeaderLength = 0; - if(!readU32L(patternHeaderLength) || patternHeaderLength < 4) + if (!readU32L(patternHeaderLength) || patternHeaderLength < 4) return false; seek(pos + 7); @@ -441,49 +390,49 @@ bool XM::File::save() const StringList lines = d->tag.comment().split("\n"); unsigned int sampleNameIndex = instrumentCount; - for(unsigned short i = 0; i < instrumentCount; ++ i) { + for (unsigned short i = 0; i < instrumentCount; ++i) { seek(pos); unsigned long instrumentHeaderSize = 0; - if(!readU32L(instrumentHeaderSize) || instrumentHeaderSize < 4) + if (!readU32L(instrumentHeaderSize) || instrumentHeaderSize < 4) return false; seek(pos + 4); const unsigned int len = std::min(22UL, instrumentHeaderSize - 4U); - if(i >= lines.size()) + if (i >= lines.size()) writeString(String(), len); else writeString(lines[i], len); unsigned short sampleCount = 0; - if(instrumentHeaderSize >= 29U) { + if (instrumentHeaderSize >= 29U) { seek(pos + 27); - if(!readU16L(sampleCount)) + if (!readU16L(sampleCount)) return false; } unsigned long sampleHeaderSize = 0; - if(sampleCount > 0) { + if (sampleCount > 0) { seek(pos + 29); - if(instrumentHeaderSize < 33U || !readU32L(sampleHeaderSize)) + if (instrumentHeaderSize < 33U || !readU32L(sampleHeaderSize)) return false; } pos += instrumentHeaderSize; - for(unsigned short j = 0; j < sampleCount; ++ j) { - if(sampleHeaderSize > 4U) { + for (unsigned short j = 0; j < sampleCount; ++j) { + if (sampleHeaderSize > 4U) { seek(pos); unsigned long sampleLength = 0; - if(!readU32L(sampleLength)) + if (!readU32L(sampleLength)) return false; - if(sampleHeaderSize > 18U) { + if (sampleHeaderSize > 18U) { seek(pos + 18); const unsigned int len2 = std::min(sampleHeaderSize - 18U, 22UL); - if(sampleNameIndex >= lines.size()) + if (sampleNameIndex >= lines.size()) writeString(String(), len2); else - writeString(lines[sampleNameIndex ++], len2); + writeString(lines[sampleNameIndex++], len2); } } pos += sampleHeaderSize; @@ -493,9 +442,8 @@ bool XM::File::save() return true; } -void XM::File::read(bool) -{ - if(!isOpen()) +void XM::File::read(bool) { + if (!isOpen()) return; seek(0); @@ -514,24 +462,24 @@ void XM::File::read(bool) READ_U32L_AS(headerSize); READ_ASSERT(headerSize >= 4); - unsigned short length = 0; + unsigned short length = 0; unsigned short restartPosition = 0; - unsigned short channels = 0; - unsigned short patternCount = 0; + unsigned short channels = 0; + unsigned short patternCount = 0; unsigned short instrumentCount = 0; - unsigned short flags = 0; - unsigned short tempo = 0; + unsigned short flags = 0; + unsigned short tempo = 0; unsigned short bpmSpeed = 0; StructReader header; header.u16L(length) - .u16L(restartPosition) - .u16L(channels) - .u16L(patternCount) - .u16L(instrumentCount) - .u16L(flags) - .u16L(tempo) - .u16L(bpmSpeed); + .u16L(restartPosition) + .u16L(channels) + .u16L(patternCount) + .u16L(instrumentCount) + .u16L(flags) + .u16L(tempo) + .u16L(bpmSpeed); unsigned int count = header.read(*this, headerSize - 4U); unsigned int size = std::min(headerSize - 4U, (unsigned long)header.size()); @@ -550,11 +498,11 @@ void XM::File::read(bool) seek(60 + headerSize); // read patterns: - for(unsigned short i = 0; i < patternCount; ++ i) { + for (unsigned short i = 0; i < patternCount; ++i) { READ_U32L_AS(patternHeaderLength); READ_ASSERT(patternHeaderLength >= 4); - unsigned char packingType = 0; + unsigned char packingType = 0; unsigned short rowCount = 0; unsigned short dataSize = 0; StructReader pattern; @@ -571,12 +519,12 @@ void XM::File::read(bool) unsigned int sumSampleCount = 0; // read instruments: - for(unsigned short i = 0; i < instrumentCount; ++ i) { + for (unsigned short i = 0; i < instrumentCount; ++i) { READ_U32L_AS(instrumentHeaderSize); READ_ASSERT(instrumentHeaderSize >= 4); String instrumentName; - unsigned char instrumentType = 0; + unsigned char instrumentType = 0; unsigned short sampleCount = 0; StructReader instrument; @@ -587,7 +535,7 @@ void XM::File::read(bool) READ_ASSERT(count2 == std::min(instrumentHeaderSize, (unsigned long)instrument.size() + 4)); long offset = 0; - if(sampleCount > 0) { + if (sampleCount > 0) { unsigned long sampleHeaderSize = 0; sumSampleCount += sampleCount; // wouldn't know which header size to assume otherwise: @@ -595,28 +543,28 @@ void XM::File::read(bool) // skip unhandled header proportion: seek(instrumentHeaderSize - count2 - 4, Current); - for(unsigned short j = 0; j < sampleCount; ++ j) { + for (unsigned short j = 0; j < sampleCount; ++j) { unsigned long sampleLength = 0; - unsigned long loopStart = 0; - unsigned long loopLength = 0; - unsigned char volume = 0; - unsigned char finetune = 0; - unsigned char sampleType = 0; - unsigned char panning = 0; - unsigned char noteNumber = 0; - unsigned char compression = 0; + unsigned long loopStart = 0; + unsigned long loopLength = 0; + unsigned char volume = 0; + unsigned char finetune = 0; + unsigned char sampleType = 0; + unsigned char panning = 0; + unsigned char noteNumber = 0; + unsigned char compression = 0; String sampleName; StructReader sample; sample.u32L(sampleLength) - .u32L(loopStart) - .u32L(loopLength) - .byte(volume) - .byte(finetune) - .byte(sampleType) - .byte(panning) - .byte(noteNumber) - .byte(compression) - .string(sampleName, 22); + .u32L(loopStart) + .u32L(loopLength) + .byte(volume) + .byte(finetune) + .byte(sampleType) + .byte(panning) + .byte(noteNumber) + .byte(compression) + .string(sampleName, 22); unsigned int count3 = sample.read(*this, sampleHeaderSize); READ_ASSERT(count3 == std::min(sampleHeaderSize, (unsigned long)sample.size())); @@ -636,7 +584,7 @@ void XM::File::read(bool) d->properties.setSampleCount(sumSampleCount); String comment(intrumentNames.toString("\n")); - if(!sampleNames.isEmpty()) { + if (!sampleNames.isEmpty()) { comment += "\n"; comment += sampleNames.toString("\n"); } diff --git a/3rdparty/taglib/xm/xmfile.h b/3rdparty/taglib/xm/xmfile.h index 603d26db9..1baba1b1b 100644 --- a/3rdparty/taglib/xm/xmfile.h +++ b/3rdparty/taglib/xm/xmfile.h @@ -36,22 +36,22 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace XM { +namespace XM { - class TAGLIB_EXPORT File : public Mod::FileBase { - public: - /*! +class TAGLIB_EXPORT File : public Mod::FileBase { + public: + /*! * Constructs an Extended Module file from \a file. * * \note In the current implementation, both \a readProperties and * \a propertiesStyle are ignored. The audio properties are always * read. */ - File(FileName file, bool readProperties = true, - AudioProperties::ReadStyle propertiesStyle = - AudioProperties::Average); + File(FileName file, bool readProperties = true, + AudioProperties::ReadStyle propertiesStyle = + AudioProperties::Average); - /*! + /*! * Constructs an Extended Module file from \a stream. * * \note In the current implementation, both \a readProperties and @@ -61,54 +61,54 @@ namespace TagLib { * \note TagLib will *not* take ownership of the stream, the caller is * responsible for deleting it after the File object. */ - File(IOStream *stream, bool readProperties = true, - AudioProperties::ReadStyle propertiesStyle = - AudioProperties::Average); + File(IOStream *stream, bool readProperties = true, + AudioProperties::ReadStyle propertiesStyle = + AudioProperties::Average); - /*! + /*! * Destroys this instance of the File. */ - virtual ~File(); + virtual ~File(); - Mod::Tag *tag() const; + Mod::Tag *tag() const; - /*! + /*! * Implements the unified property interface -- export function. * Forwards to Mod::Tag::properties(). */ - PropertyMap properties() const; + PropertyMap properties() const; - /*! + /*! * Implements the unified property interface -- import function. * Forwards to Mod::Tag::setProperties(). */ - PropertyMap setProperties(const PropertyMap &); + PropertyMap setProperties(const PropertyMap &); - /*! + /*! * Returns the XM::Properties for this file. If no audio properties * were read then this will return a null pointer. */ - XM::Properties *audioProperties() const; + XM::Properties *audioProperties() const; - /*! + /*! * Save the file. * This is the same as calling save(AllTags); * * \note Saving Extended Module tags is not supported. */ - bool save(); + bool save(); - private: - File(const File &); - File &operator=(const File &); + private: + File(const File &); + File &operator=(const File &); - void read(bool readProperties); + void read(bool readProperties); - class FilePrivate; - FilePrivate *d; - }; - } -} -} + class FilePrivate; + FilePrivate *d; +}; +} // namespace XM +} // namespace TagLib +} // namespace Strawberry_TagLib #endif diff --git a/3rdparty/taglib/xm/xmproperties.cpp b/3rdparty/taglib/xm/xmproperties.cpp index ad1e9d3ad..db9fbc403 100644 --- a/3rdparty/taglib/xm/xmproperties.cpp +++ b/3rdparty/taglib/xm/xmproperties.cpp @@ -29,167 +29,136 @@ using namespace Strawberry_TagLib::TagLib; using namespace XM; -class XM::Properties::PropertiesPrivate -{ -public: - PropertiesPrivate() : - lengthInPatterns(0), - channels(0), - version(0), - restartPosition(0), - patternCount(0), - instrumentCount(0), - sampleCount(0), - flags(0), - tempo(0), - bpmSpeed(0) - { +class XM::Properties::PropertiesPrivate { + public: + PropertiesPrivate() : lengthInPatterns(0), + channels(0), + version(0), + restartPosition(0), + patternCount(0), + instrumentCount(0), + sampleCount(0), + flags(0), + tempo(0), + bpmSpeed(0) { } unsigned short lengthInPatterns; - int channels; + int channels; unsigned short version; unsigned short restartPosition; unsigned short patternCount; unsigned short instrumentCount; - unsigned int sampleCount; + unsigned int sampleCount; unsigned short flags; unsigned short tempo; unsigned short bpmSpeed; }; -XM::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) : - AudioProperties(propertiesStyle), - d(new PropertiesPrivate()) -{ +XM::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) : AudioProperties(propertiesStyle), + d(new PropertiesPrivate()) { } -XM::Properties::~Properties() -{ +XM::Properties::~Properties() { delete d; } -int XM::Properties::length() const -{ +int XM::Properties::length() const { return 0; } -int XM::Properties::lengthInSeconds() const -{ +int XM::Properties::lengthInSeconds() const { return 0; } -int XM::Properties::lengthInMilliseconds() const -{ +int XM::Properties::lengthInMilliseconds() const { return 0; } -int XM::Properties::bitrate() const -{ +int XM::Properties::bitrate() const { return 0; } -int XM::Properties::sampleRate() const -{ +int XM::Properties::sampleRate() const { return 0; } -int XM::Properties::channels() const -{ +int XM::Properties::channels() const { return d->channels; } -unsigned short XM::Properties::lengthInPatterns() const -{ +unsigned short XM::Properties::lengthInPatterns() const { return d->lengthInPatterns; } -unsigned short XM::Properties::version() const -{ +unsigned short XM::Properties::version() const { return d->version; } -unsigned short XM::Properties::restartPosition() const -{ +unsigned short XM::Properties::restartPosition() const { return d->restartPosition; } -unsigned short XM::Properties::patternCount() const -{ +unsigned short XM::Properties::patternCount() const { return d->patternCount; } -unsigned short XM::Properties::instrumentCount() const -{ +unsigned short XM::Properties::instrumentCount() const { return d->instrumentCount; } -unsigned int XM::Properties::sampleCount() const -{ +unsigned int XM::Properties::sampleCount() const { return d->sampleCount; } -unsigned short XM::Properties::flags() const -{ +unsigned short XM::Properties::flags() const { return d->flags; } -unsigned short XM::Properties::tempo() const -{ +unsigned short XM::Properties::tempo() const { return d->tempo; } -unsigned short XM::Properties::bpmSpeed() const -{ +unsigned short XM::Properties::bpmSpeed() const { return d->bpmSpeed; } -void XM::Properties::setLengthInPatterns(unsigned short lengthInPatterns) -{ +void XM::Properties::setLengthInPatterns(unsigned short lengthInPatterns) { d->lengthInPatterns = lengthInPatterns; } -void XM::Properties::setChannels(int channels) -{ +void XM::Properties::setChannels(int channels) { d->channels = channels; } -void XM::Properties::setVersion(unsigned short version) -{ +void XM::Properties::setVersion(unsigned short version) { d->version = version; } -void XM::Properties::setRestartPosition(unsigned short restartPosition) -{ +void XM::Properties::setRestartPosition(unsigned short restartPosition) { d->restartPosition = restartPosition; } -void XM::Properties::setPatternCount(unsigned short patternCount) -{ +void XM::Properties::setPatternCount(unsigned short patternCount) { d->patternCount = patternCount; } -void XM::Properties::setInstrumentCount(unsigned short instrumentCount) -{ +void XM::Properties::setInstrumentCount(unsigned short instrumentCount) { d->instrumentCount = instrumentCount; } -void XM::Properties::setSampleCount(unsigned int sampleCount) -{ +void XM::Properties::setSampleCount(unsigned int sampleCount) { d->sampleCount = sampleCount; } -void XM::Properties::setFlags(unsigned short flags) -{ +void XM::Properties::setFlags(unsigned short flags) { d->flags = flags; } -void XM::Properties::setTempo(unsigned short tempo) -{ +void XM::Properties::setTempo(unsigned short tempo) { d->tempo = tempo; } -void XM::Properties::setBpmSpeed(unsigned short bpmSpeed) -{ +void XM::Properties::setBpmSpeed(unsigned short bpmSpeed) { d->bpmSpeed = bpmSpeed; } diff --git a/3rdparty/taglib/xm/xmproperties.h b/3rdparty/taglib/xm/xmproperties.h index 9370901dd..16759bc1a 100644 --- a/3rdparty/taglib/xm/xmproperties.h +++ b/3rdparty/taglib/xm/xmproperties.h @@ -32,56 +32,57 @@ namespace Strawberry_TagLib { namespace TagLib { - namespace XM { - class TAGLIB_EXPORT Properties : public AudioProperties { - friend class File; - public: - /*! Flag bits. */ - enum { - LinearFreqTable = 1 // otherwise its the amiga freq. table - }; +namespace XM { +class TAGLIB_EXPORT Properties : public AudioProperties { + friend class File; - Properties(AudioProperties::ReadStyle propertiesStyle); - virtual ~Properties(); + public: + /*! Flag bits. */ + enum { + LinearFreqTable = 1 // otherwise its the amiga freq. table + }; - int length() const; - int lengthInSeconds() const; - int lengthInMilliseconds() const; - int bitrate() const; - int sampleRate() const; - int channels() const; + Properties(AudioProperties::ReadStyle propertiesStyle); + virtual ~Properties(); - unsigned short lengthInPatterns() const; - unsigned short version() const; - unsigned short restartPosition() const; - unsigned short patternCount() const; - unsigned short instrumentCount() const; - unsigned int sampleCount() const; - unsigned short flags() const; - unsigned short tempo() const; - unsigned short bpmSpeed() const; + int length() const; + int lengthInSeconds() const; + int lengthInMilliseconds() const; + int bitrate() const; + int sampleRate() const; + int channels() const; - void setChannels(int channels); + unsigned short lengthInPatterns() const; + unsigned short version() const; + unsigned short restartPosition() const; + unsigned short patternCount() const; + unsigned short instrumentCount() const; + unsigned int sampleCount() const; + unsigned short flags() const; + unsigned short tempo() const; + unsigned short bpmSpeed() const; - void setLengthInPatterns(unsigned short lengthInPatterns); - void setVersion(unsigned short version); - void setRestartPosition(unsigned short restartPosition); - void setPatternCount(unsigned short patternCount); - void setInstrumentCount(unsigned short instrumentCount); - void setSampleCount(unsigned int sampleCount); - void setFlags(unsigned short flags); - void setTempo(unsigned short tempo); - void setBpmSpeed(unsigned short bpmSpeed); + void setChannels(int channels); - private: - Properties(const Properties&); - Properties &operator=(const Properties&); + void setLengthInPatterns(unsigned short lengthInPatterns); + void setVersion(unsigned short version); + void setRestartPosition(unsigned short restartPosition); + void setPatternCount(unsigned short patternCount); + void setInstrumentCount(unsigned short instrumentCount); + void setSampleCount(unsigned int sampleCount); + void setFlags(unsigned short flags); + void setTempo(unsigned short tempo); + void setBpmSpeed(unsigned short bpmSpeed); - class PropertiesPrivate; - PropertiesPrivate *d; - }; - } -} -} + private: + Properties(const Properties &); + Properties &operator=(const Properties &); + + class PropertiesPrivate; + PropertiesPrivate *d; +}; +} // namespace XM +} // namespace TagLib +} // namespace Strawberry_TagLib #endif