Adapt most changes from taglib2
This commit is contained in:
139
3rdparty/taglib/flac/flacfile.cpp
vendored
139
3rdparty/taglib/flac/flacfile.cpp
vendored
@@ -23,18 +23,20 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tbytevector.h>
|
||||
#include <tstring.h>
|
||||
#include <tlist.h>
|
||||
#include <tdebug.h>
|
||||
#include <tagunion.h>
|
||||
#include <tpropertymap.h>
|
||||
#include <tagutils.h>
|
||||
#include <memory>
|
||||
|
||||
#include <id3v2header.h>
|
||||
#include <id3v2tag.h>
|
||||
#include <id3v1tag.h>
|
||||
#include <xiphcomment.h>
|
||||
#include "tbytevector.h"
|
||||
#include "tstring.h"
|
||||
#include "tlist.h"
|
||||
#include "tdebug.h"
|
||||
#include "tagunion.h"
|
||||
#include "tpropertymap.h"
|
||||
#include "tagutils.h"
|
||||
|
||||
#include "id3v2header.h"
|
||||
#include "id3v2tag.h"
|
||||
#include "id3v1tag.h"
|
||||
#include "xiphcomment.h"
|
||||
|
||||
#include "flacpicture.h"
|
||||
#include "flacfile.h"
|
||||
@@ -44,7 +46,7 @@
|
||||
using namespace Strawberry_TagLib::TagLib;
|
||||
|
||||
namespace {
|
||||
typedef List<FLAC::MetadataBlock *> BlockList;
|
||||
typedef List<std::shared_ptr<FLAC::MetadataBlock>> BlockList;
|
||||
typedef BlockList::Iterator BlockIterator;
|
||||
typedef BlockList::Iterator BlockConstIterator;
|
||||
|
||||
@@ -52,43 +54,54 @@ enum { FlacXiphIndex = 0,
|
||||
FlacID3v2Index = 1,
|
||||
FlacID3v1Index = 2 };
|
||||
|
||||
const long MinPaddingLength = 4096;
|
||||
const long MaxPaddingLegnth = 1024 * 1024;
|
||||
const long long MinPaddingLength = 4096;
|
||||
const long long MaxPaddingLegnth = 1024 * 1024;
|
||||
|
||||
const char LastBlockFlag = '\x80';
|
||||
} // namespace
|
||||
|
||||
namespace Strawberry_TagLib {
|
||||
namespace TagLib {
|
||||
namespace FLAC {
|
||||
// Enables BlockList::find() to take raw pointers.
|
||||
|
||||
bool operator==(std::shared_ptr<MetadataBlock> lhs, MetadataBlock *rhs);
|
||||
bool operator==(std::shared_ptr<MetadataBlock> lhs, MetadataBlock *rhs) {
|
||||
return lhs.get() == rhs;
|
||||
}
|
||||
} // namespace FLAC
|
||||
} // namespace TagLib
|
||||
} // namespace Strawberry_TagLib
|
||||
|
||||
class FLAC::File::FilePrivate {
|
||||
public:
|
||||
explicit FilePrivate(const ID3v2::FrameFactory *frameFactory = ID3v2::FrameFactory::instance()) : ID3v2FrameFactory(frameFactory),
|
||||
ID3v2Location(-1),
|
||||
ID3v2OriginalSize(0),
|
||||
ID3v1Location(-1),
|
||||
properties(nullptr),
|
||||
flacStart(0),
|
||||
streamStart(0),
|
||||
scanned(false) {
|
||||
blocks.setAutoDelete(true);
|
||||
}
|
||||
explicit FilePrivate(const ID3v2::FrameFactory *frameFactory) : ID3v2FrameFactory(ID3v2::FrameFactory::instance()),
|
||||
ID3v2Location(-1),
|
||||
ID3v2OriginalSize(0),
|
||||
ID3v1Location(-1),
|
||||
flacStart(0),
|
||||
streamStart(0),
|
||||
scanned(false) {
|
||||
|
||||
if (frameFactory)
|
||||
ID3v2FrameFactory = frameFactory;
|
||||
|
||||
~FilePrivate() {
|
||||
delete properties;
|
||||
}
|
||||
|
||||
const ID3v2::FrameFactory *ID3v2FrameFactory;
|
||||
long ID3v2Location;
|
||||
long ID3v2OriginalSize;
|
||||
long long ID3v2Location;
|
||||
long long ID3v2OriginalSize;
|
||||
|
||||
long ID3v1Location;
|
||||
long long ID3v1Location;
|
||||
|
||||
TagUnion tag;
|
||||
TripleTagUnion tag;
|
||||
|
||||
AudioProperties *properties;
|
||||
std::unique_ptr<AudioProperties> properties;
|
||||
ByteVector xiphCommentData;
|
||||
BlockList blocks;
|
||||
|
||||
long flacStart;
|
||||
long streamStart;
|
||||
long long flacStart;
|
||||
long long streamStart;
|
||||
bool scanned;
|
||||
};
|
||||
|
||||
@@ -101,7 +114,7 @@ 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);
|
||||
return (buffer.find("fLaC") >= 0);
|
||||
return (buffer.find("fLaC") != ByteVector::npos());
|
||||
|
||||
}
|
||||
|
||||
@@ -109,14 +122,14 @@ bool FLAC::File::isSupported(IOStream *stream) {
|
||||
// public members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
FLAC::File::File(FileName file, ID3v2::FrameFactory *frameFactory, bool readProperties, AudioProperties::ReadStyle) : Strawberry_TagLib::TagLib::File(file), d(new FilePrivate(frameFactory)) {
|
||||
FLAC::File::File(FileName file, bool readProperties, AudioProperties::ReadStyle, ID3v2::FrameFactory *frameFactory) : Strawberry_TagLib::TagLib::File(file), d(new FilePrivate(frameFactory)) {
|
||||
|
||||
if (isOpen())
|
||||
read(readProperties);
|
||||
|
||||
}
|
||||
|
||||
FLAC::File::File(IOStream *stream, ID3v2::FrameFactory *frameFactory, bool readProperties, AudioProperties::ReadStyle) : Strawberry_TagLib::TagLib::File(stream), d(new FilePrivate(frameFactory)) {
|
||||
FLAC::File::File(IOStream *stream, bool readProperties, AudioProperties::ReadStyle, ID3v2::FrameFactory *frameFactory) : Strawberry_TagLib::TagLib::File(stream), d(new FilePrivate(frameFactory)) {
|
||||
|
||||
if (isOpen())
|
||||
read(readProperties);
|
||||
@@ -131,20 +144,12 @@ Strawberry_TagLib::TagLib::Tag *FLAC::File::tag() const {
|
||||
return &d->tag;
|
||||
}
|
||||
|
||||
PropertyMap FLAC::File::properties() const {
|
||||
return d->tag.properties();
|
||||
}
|
||||
|
||||
void FLAC::File::removeUnsupportedProperties(const StringList &unsupported) {
|
||||
d->tag.removeUnsupportedProperties(unsupported);
|
||||
}
|
||||
|
||||
PropertyMap FLAC::File::setProperties(const PropertyMap &properties) {
|
||||
return xiphComment(true)->setProperties(properties);
|
||||
}
|
||||
|
||||
FLAC::AudioProperties *FLAC::File::audioProperties() const {
|
||||
return d->properties;
|
||||
return d->properties.get();
|
||||
}
|
||||
|
||||
bool FLAC::File::save() {
|
||||
@@ -170,20 +175,19 @@ bool FLAC::File::save() {
|
||||
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);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
d->blocks.append(new UnknownMetadataBlock(MetadataBlock::VorbisComment, d->xiphCommentData));
|
||||
d->blocks.append(std::shared_ptr<MetadataBlock>(new UnknownMetadataBlock(MetadataBlock::VorbisComment, d->xiphCommentData)));
|
||||
|
||||
// Render data for the metadata blocks
|
||||
|
||||
ByteVector data;
|
||||
for (BlockConstIterator it = d->blocks.begin(); it != d->blocks.end(); ++it) {
|
||||
ByteVector blockData = (*it)->render();
|
||||
ByteVector blockHeader = ByteVector::fromUInt(blockData.size());
|
||||
ByteVector blockHeader = ByteVector::fromUInt32BE(blockData.size());
|
||||
blockHeader[0] = (*it)->code();
|
||||
data.append(blockHeader);
|
||||
data.append(blockData);
|
||||
@@ -191,8 +195,8 @@ bool FLAC::File::save() {
|
||||
|
||||
// Compute the amount of padding, and append that to data.
|
||||
|
||||
long originalLength = d->streamStart - d->flacStart;
|
||||
long paddingLength = originalLength - data.size() - 4;
|
||||
long long originalLength = d->streamStart - d->flacStart;
|
||||
long long paddingLength = originalLength - data.size() - 4;
|
||||
|
||||
if (paddingLength <= 0) {
|
||||
paddingLength = MinPaddingLength;
|
||||
@@ -200,7 +204,7 @@ bool FLAC::File::save() {
|
||||
else {
|
||||
// Padding won't increase beyond 1% of the file size or 1MB.
|
||||
|
||||
long threshold = length() / 100;
|
||||
long long threshold = length() / 100;
|
||||
threshold = std::max(threshold, MinPaddingLength);
|
||||
threshold = std::min(threshold, MaxPaddingLegnth);
|
||||
|
||||
@@ -208,10 +212,10 @@ bool FLAC::File::save() {
|
||||
paddingLength = MinPaddingLength;
|
||||
}
|
||||
|
||||
ByteVector paddingHeader = ByteVector::fromUInt(paddingLength);
|
||||
ByteVector paddingHeader = ByteVector::fromUInt32BE(paddingLength);
|
||||
paddingHeader[0] = static_cast<char>(MetadataBlock::Padding | LastBlockFlag);
|
||||
data.append(paddingHeader);
|
||||
data.resize(static_cast<unsigned int>(data.size() + paddingLength));
|
||||
data.resize(static_cast<size_t>(data.size() + paddingLength));
|
||||
|
||||
// Write the data to the file
|
||||
|
||||
@@ -304,7 +308,7 @@ List<FLAC::Picture *> FLAC::File::pictureList() {
|
||||
|
||||
List<Picture *> pictures;
|
||||
for (BlockConstIterator it = d->blocks.begin(); it != d->blocks.end(); ++it) {
|
||||
Picture *picture = dynamic_cast<Picture *>(*it);
|
||||
Picture *picture = dynamic_cast<Picture *>(it->get());
|
||||
if (picture) {
|
||||
pictures.append(picture);
|
||||
}
|
||||
@@ -314,25 +318,21 @@ List<FLAC::Picture *> FLAC::File::pictureList() {
|
||||
}
|
||||
|
||||
void FLAC::File::addPicture(Picture *picture) {
|
||||
d->blocks.append(picture);
|
||||
d->blocks.append(std::shared_ptr<Picture>(picture));
|
||||
}
|
||||
|
||||
void FLAC::File::removePicture(Picture *picture, bool del) {
|
||||
void FLAC::File::removePicture(Picture *picture) {
|
||||
|
||||
BlockIterator it = d->blocks.find(picture);
|
||||
if (it != d->blocks.end())
|
||||
d->blocks.erase(it);
|
||||
|
||||
if (del)
|
||||
delete picture;
|
||||
|
||||
}
|
||||
|
||||
void FLAC::File::removePictures() {
|
||||
|
||||
for (BlockIterator it = d->blocks.begin(); it != d->blocks.end();) {
|
||||
if (dynamic_cast<Picture *>(*it)) {
|
||||
delete *it;
|
||||
if (dynamic_cast<Picture *>(it->get())) {
|
||||
it = d->blocks.erase(it);
|
||||
}
|
||||
else {
|
||||
@@ -409,14 +409,14 @@ void FLAC::File::read(bool readProperties) {
|
||||
|
||||
const ByteVector infoData = d->blocks.front()->render();
|
||||
|
||||
long streamLength;
|
||||
long long streamLength;
|
||||
|
||||
if (d->ID3v1Location >= 0)
|
||||
streamLength = d->ID3v1Location - d->streamStart;
|
||||
else
|
||||
streamLength = length() - d->streamStart;
|
||||
|
||||
d->properties = new AudioProperties(infoData, streamLength);
|
||||
d->properties.reset(new AudioProperties(infoData, streamLength));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -431,7 +431,7 @@ void FLAC::File::scan() {
|
||||
if (!isValid())
|
||||
return;
|
||||
|
||||
long nextBlockOffset;
|
||||
long long nextBlockOffset;
|
||||
|
||||
if (d->ID3v2Location >= 0)
|
||||
nextBlockOffset = find("fLaC", d->ID3v2Location + d->ID3v2OriginalSize);
|
||||
@@ -466,7 +466,7 @@ void FLAC::File::scan() {
|
||||
|
||||
const char blockType = header[0] & ~LastBlockFlag;
|
||||
const bool isLastBlock = (header[0] & LastBlockFlag) != 0;
|
||||
const unsigned int blockLength = header.toUInt(1U, 3U);
|
||||
const size_t blockLength = header.toUInt24BE(1);
|
||||
|
||||
// First block should be the stream_info metadata
|
||||
|
||||
@@ -489,33 +489,32 @@ void FLAC::File::scan() {
|
||||
return;
|
||||
}
|
||||
|
||||
MetadataBlock *block = nullptr;
|
||||
std::shared_ptr<MetadataBlock> block;
|
||||
|
||||
// Found the vorbis-comment
|
||||
if (blockType == MetadataBlock::VorbisComment) {
|
||||
if (d->xiphCommentData.isEmpty()) {
|
||||
d->xiphCommentData = data;
|
||||
block = new UnknownMetadataBlock(MetadataBlock::VorbisComment, data);
|
||||
block.reset(new UnknownMetadataBlock(MetadataBlock::VorbisComment, data));
|
||||
}
|
||||
else {
|
||||
debug("FLAC::File::scan() -- multiple Vorbis Comment blocks found, discarding");
|
||||
}
|
||||
}
|
||||
else if (blockType == MetadataBlock::Picture) {
|
||||
FLAC::Picture *picture = new FLAC::Picture();
|
||||
std::shared_ptr<FLAC::Picture> picture(new FLAC::Picture());
|
||||
if (picture->parse(data)) {
|
||||
block = picture;
|
||||
}
|
||||
else {
|
||||
debug("FLAC::File::scan() -- invalid picture found, discarding");
|
||||
delete picture;
|
||||
}
|
||||
}
|
||||
else if (blockType == MetadataBlock::Padding) {
|
||||
// Skip all padding blocks.
|
||||
}
|
||||
else {
|
||||
block = new UnknownMetadataBlock(blockType, data);
|
||||
block.reset(new UnknownMetadataBlock(blockType, data));
|
||||
}
|
||||
|
||||
if (block)
|
||||
|
||||
31
3rdparty/taglib/flac/flacfile.h
vendored
31
3rdparty/taglib/flac/flacfile.h
vendored
@@ -26,6 +26,8 @@
|
||||
#ifndef TAGLIB_FLACFILE_H
|
||||
#define TAGLIB_FLACFILE_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "taglib_export.h"
|
||||
#include "tfile.h"
|
||||
#include "tlist.h"
|
||||
@@ -97,7 +99,7 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
|
||||
*
|
||||
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||
*/
|
||||
explicit File(FileName file, ID3v2::FrameFactory *frameFactory, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average);
|
||||
explicit File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average, ID3v2::FrameFactory *frameFactory = nullptr);
|
||||
|
||||
/*!
|
||||
* Constructs a FLAC file from \a stream. If \a readProperties is true the file's audio properties will also be read.
|
||||
@@ -109,12 +111,12 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
|
||||
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||
*/
|
||||
// BIC: merge with the above constructor
|
||||
explicit File(IOStream *stream, ID3v2::FrameFactory *frameFactory, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average);
|
||||
explicit File(IOStream *stream, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average, ID3v2::FrameFactory *frameFactory = nullptr);
|
||||
|
||||
/*!
|
||||
* Destroys this instance of the File.
|
||||
*/
|
||||
virtual ~File();
|
||||
~File() override;
|
||||
|
||||
/*!
|
||||
* Returns the Tag for this file. This will be a union of XiphComment, ID3v1 and ID3v2 tags.
|
||||
@@ -123,27 +125,19 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
|
||||
* \see ID3v1Tag()
|
||||
* \see XiphComment()
|
||||
*/
|
||||
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;
|
||||
|
||||
void removeUnsupportedProperties(const StringList &);
|
||||
Strawberry_TagLib::TagLib::Tag *tag() const override;
|
||||
|
||||
/*!
|
||||
* 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 &) override;
|
||||
|
||||
/*!
|
||||
* Returns the FLAC::AudioProperties for this file. If no audio properties were read then this will return a null pointer.
|
||||
*/
|
||||
virtual AudioProperties *audioProperties() const;
|
||||
AudioProperties *audioProperties() const override;
|
||||
|
||||
/*!
|
||||
* Save the file. This will primarily save the XiphComment, but will also keep any old ID3-tags up to date.
|
||||
@@ -151,7 +145,7 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
|
||||
*
|
||||
* This returns true if the save was successful.
|
||||
*/
|
||||
virtual bool save();
|
||||
bool save() override;
|
||||
|
||||
/*!
|
||||
* Returns a pointer to the ID3v2 tag of the file.
|
||||
@@ -208,10 +202,9 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
|
||||
List<Picture *> 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.
|
||||
* Removes an attached picture. The picture's memory will be freed.
|
||||
*/
|
||||
void removePicture(Picture *picture, bool del = true);
|
||||
void removePicture(Picture *picture);
|
||||
|
||||
/*!
|
||||
* Remove all attached images.
|
||||
@@ -269,7 +262,7 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
|
||||
static bool isSupported(IOStream *stream);
|
||||
|
||||
private:
|
||||
explicit File(const File&);
|
||||
File(const File&);
|
||||
File &operator=(const File&);
|
||||
|
||||
void read(bool readProperties);
|
||||
|
||||
4
3rdparty/taglib/flac/flacmetadatablock.cpp
vendored
4
3rdparty/taglib/flac/flacmetadatablock.cpp
vendored
@@ -23,8 +23,8 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <taglib.h>
|
||||
#include <tdebug.h>
|
||||
#include "taglib.h"
|
||||
#include "tdebug.h"
|
||||
#include "flacmetadatablock.h"
|
||||
|
||||
using namespace Strawberry_TagLib::TagLib;
|
||||
|
||||
2
3rdparty/taglib/flac/flacmetadatablock.h
vendored
2
3rdparty/taglib/flac/flacmetadatablock.h
vendored
@@ -60,7 +60,7 @@ class TAGLIB_EXPORT MetadataBlock {
|
||||
virtual ByteVector render() const = 0;
|
||||
|
||||
private:
|
||||
explicit MetadataBlock(const MetadataBlock &item);
|
||||
MetadataBlock(const MetadataBlock &item);
|
||||
MetadataBlock &operator=(const MetadataBlock &item);
|
||||
|
||||
class MetadataBlockPrivate;
|
||||
|
||||
48
3rdparty/taglib/flac/flacpicture.cpp
vendored
48
3rdparty/taglib/flac/flacpicture.cpp
vendored
@@ -23,19 +23,19 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <taglib.h>
|
||||
#include <tdebug.h>
|
||||
#include "taglib.h"
|
||||
#include "tdebug.h"
|
||||
#include "flacpicture.h"
|
||||
|
||||
using namespace Strawberry_TagLib::TagLib;
|
||||
|
||||
class FLAC::Picture::PicturePrivate {
|
||||
public:
|
||||
PicturePrivate() : type(FLAC::Picture::Other),
|
||||
width(0),
|
||||
height(0),
|
||||
colorDepth(0),
|
||||
numColors(0) {
|
||||
explicit PicturePrivate() : type(FLAC::Picture::Other),
|
||||
width(0),
|
||||
height(0),
|
||||
colorDepth(0),
|
||||
numColors(0) {
|
||||
}
|
||||
|
||||
Type type;
|
||||
@@ -70,10 +70,10 @@ bool FLAC::Picture::parse(const ByteVector &data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int pos = 0;
|
||||
d->type = FLAC::Picture::Type(data.toUInt(pos));
|
||||
size_t pos = 0;
|
||||
d->type = FLAC::Picture::Type(data.toUInt32BE(pos));
|
||||
pos += 4;
|
||||
unsigned int mimeTypeLength = data.toUInt(pos);
|
||||
const unsigned int mimeTypeLength = data.toUInt32BE(pos);
|
||||
pos += 4;
|
||||
if (pos + mimeTypeLength + 24 > data.size()) {
|
||||
debug("Invalid picture block.");
|
||||
@@ -81,7 +81,7 @@ bool FLAC::Picture::parse(const ByteVector &data) {
|
||||
}
|
||||
d->mimeType = String(data.mid(pos, mimeTypeLength), String::UTF8);
|
||||
pos += mimeTypeLength;
|
||||
unsigned int descriptionLength = data.toUInt(pos);
|
||||
const unsigned int descriptionLength = data.toUInt32BE(pos);
|
||||
pos += 4;
|
||||
if (pos + descriptionLength + 20 > data.size()) {
|
||||
debug("Invalid picture block.");
|
||||
@@ -89,15 +89,15 @@ bool FLAC::Picture::parse(const ByteVector &data) {
|
||||
}
|
||||
d->description = String(data.mid(pos, descriptionLength), String::UTF8);
|
||||
pos += descriptionLength;
|
||||
d->width = data.toUInt(pos);
|
||||
d->width = data.toUInt32BE(pos);
|
||||
pos += 4;
|
||||
d->height = data.toUInt(pos);
|
||||
d->height = data.toUInt32BE(pos);
|
||||
pos += 4;
|
||||
d->colorDepth = data.toUInt(pos);
|
||||
d->colorDepth = data.toUInt32BE(pos);
|
||||
pos += 4;
|
||||
d->numColors = data.toUInt(pos);
|
||||
d->numColors = data.toUInt32BE(pos);
|
||||
pos += 4;
|
||||
unsigned int dataLength = data.toUInt(pos);
|
||||
const unsigned int dataLength = data.toUInt32BE(pos);
|
||||
pos += 4;
|
||||
if (pos + dataLength > data.size()) {
|
||||
debug("Invalid picture block.");
|
||||
@@ -112,18 +112,18 @@ bool FLAC::Picture::parse(const ByteVector &data) {
|
||||
ByteVector FLAC::Picture::render() const {
|
||||
|
||||
ByteVector result;
|
||||
result.append(ByteVector::fromUInt(d->type));
|
||||
result.append(ByteVector::fromUInt32BE(d->type));
|
||||
ByteVector mimeTypeData = d->mimeType.data(String::UTF8);
|
||||
result.append(ByteVector::fromUInt(mimeTypeData.size()));
|
||||
result.append(ByteVector::fromUInt32BE(mimeTypeData.size()));
|
||||
result.append(mimeTypeData);
|
||||
ByteVector descriptionData = d->description.data(String::UTF8);
|
||||
result.append(ByteVector::fromUInt(descriptionData.size()));
|
||||
result.append(ByteVector::fromUInt32BE(descriptionData.size()));
|
||||
result.append(descriptionData);
|
||||
result.append(ByteVector::fromUInt(d->width));
|
||||
result.append(ByteVector::fromUInt(d->height));
|
||||
result.append(ByteVector::fromUInt(d->colorDepth));
|
||||
result.append(ByteVector::fromUInt(d->numColors));
|
||||
result.append(ByteVector::fromUInt(d->data.size()));
|
||||
result.append(ByteVector::fromUInt32BE(d->width));
|
||||
result.append(ByteVector::fromUInt32BE(d->height));
|
||||
result.append(ByteVector::fromUInt32BE(d->colorDepth));
|
||||
result.append(ByteVector::fromUInt32BE(d->numColors));
|
||||
result.append(ByteVector::fromUInt32BE(d->data.size()));
|
||||
result.append(d->data);
|
||||
return result;
|
||||
|
||||
|
||||
10
3rdparty/taglib/flac/flacpicture.h
vendored
10
3rdparty/taglib/flac/flacpicture.h
vendored
@@ -89,7 +89,7 @@ class TAGLIB_EXPORT Picture : public MetadataBlock {
|
||||
|
||||
explicit Picture();
|
||||
explicit Picture(const ByteVector &data);
|
||||
~Picture();
|
||||
~Picture() override;
|
||||
|
||||
/*!
|
||||
* Returns the type of the image.
|
||||
@@ -176,12 +176,12 @@ class TAGLIB_EXPORT Picture : public MetadataBlock {
|
||||
/*!
|
||||
* Returns the FLAC metadata block type.
|
||||
*/
|
||||
int code() const;
|
||||
int code() const override;
|
||||
|
||||
/*!
|
||||
* Render the content to the FLAC picture block format.
|
||||
*/
|
||||
ByteVector render() const;
|
||||
ByteVector render() const override;
|
||||
|
||||
/*!
|
||||
* Parse the picture data in the FLAC picture block format.
|
||||
@@ -189,15 +189,13 @@ class TAGLIB_EXPORT Picture : public MetadataBlock {
|
||||
bool parse(const ByteVector &rawData);
|
||||
|
||||
private:
|
||||
explicit Picture(const Picture &item);
|
||||
Picture(const Picture &item);
|
||||
Picture &operator=(const Picture &item);
|
||||
|
||||
class PicturePrivate;
|
||||
PicturePrivate *d;
|
||||
};
|
||||
|
||||
typedef List<Picture> PictureList;
|
||||
|
||||
} // namespace FLAC
|
||||
} // namespace TagLib
|
||||
} // namespace Strawberry_TagLib
|
||||
|
||||
26
3rdparty/taglib/flac/flacproperties.cpp
vendored
26
3rdparty/taglib/flac/flacproperties.cpp
vendored
@@ -23,8 +23,8 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tstring.h>
|
||||
#include <tdebug.h>
|
||||
#include "tstring.h"
|
||||
#include "tdebug.h"
|
||||
|
||||
#include "flacproperties.h"
|
||||
#include "flacfile.h"
|
||||
@@ -33,12 +33,12 @@ using namespace Strawberry_TagLib::TagLib;
|
||||
|
||||
class FLAC::AudioProperties::AudioPropertiesPrivate {
|
||||
public:
|
||||
AudioPropertiesPrivate() : length(0),
|
||||
bitrate(0),
|
||||
sampleRate(0),
|
||||
bitsPerSample(0),
|
||||
channels(0),
|
||||
sampleFrames(0) {}
|
||||
explicit AudioPropertiesPrivate() : length(0),
|
||||
bitrate(0),
|
||||
sampleRate(0),
|
||||
bitsPerSample(0),
|
||||
channels(0),
|
||||
sampleFrames(0) {}
|
||||
|
||||
int length;
|
||||
int bitrate;
|
||||
@@ -53,7 +53,7 @@ class FLAC::AudioProperties::AudioPropertiesPrivate {
|
||||
// public members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
FLAC::AudioProperties::AudioProperties(const ByteVector &data, long streamLength, ReadStyle style) : Strawberry_TagLib::TagLib::AudioProperties(style), d(new AudioPropertiesPrivate()) {
|
||||
FLAC::AudioProperties::AudioProperties(const ByteVector &data, long long streamLength, ReadStyle) : Strawberry_TagLib::TagLib::AudioProperties(), d(new AudioPropertiesPrivate()) {
|
||||
read(data, streamLength);
|
||||
}
|
||||
|
||||
@@ -97,14 +97,14 @@ ByteVector FLAC::AudioProperties::signature() const {
|
||||
// private members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void FLAC::AudioProperties::read(const ByteVector &data, long streamLength) {
|
||||
void FLAC::AudioProperties::read(const ByteVector &data, long long streamLength) {
|
||||
|
||||
if (data.size() < 18) {
|
||||
debug("FLAC::AudioProperties::read() - FLAC properties must contain at least 18 bytes.");
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int pos = 0;
|
||||
size_t pos = 0;
|
||||
|
||||
// Minimum block size (in samples)
|
||||
pos += 2;
|
||||
@@ -118,7 +118,7 @@ void FLAC::AudioProperties::read(const ByteVector &data, long streamLength) {
|
||||
// Maximum frame size (in bytes)
|
||||
pos += 3;
|
||||
|
||||
const unsigned int flags = data.toUInt(pos, true);
|
||||
const unsigned int flags = data.toUInt32BE(pos);
|
||||
pos += 4;
|
||||
|
||||
d->sampleRate = flags >> 12;
|
||||
@@ -129,7 +129,7 @@ void FLAC::AudioProperties::read(const ByteVector &data, long streamLength) {
|
||||
// stream length in samples. (Audio files measured in days)
|
||||
|
||||
const unsigned long long hi = flags & 0xf;
|
||||
const unsigned long long lo = data.toUInt(pos, true);
|
||||
const unsigned long long lo = data.toUInt32BE(pos);
|
||||
pos += 4;
|
||||
|
||||
d->sampleFrames = (hi << 32) | lo;
|
||||
|
||||
19
3rdparty/taglib/flac/flacproperties.h
vendored
19
3rdparty/taglib/flac/flacproperties.h
vendored
@@ -47,41 +47,41 @@ class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioPro
|
||||
/*!
|
||||
* Create an instance of FLAC::AudioProperties with the data read from the ByteVector \a data.
|
||||
*/
|
||||
explicit AudioProperties(const ByteVector &data, long streamLength, ReadStyle style = Average);
|
||||
explicit AudioProperties(const ByteVector &data, long long streamLength, ReadStyle style = Average);
|
||||
|
||||
/*!
|
||||
* Destroys this FLAC::AudioProperties instance.
|
||||
*/
|
||||
virtual ~AudioProperties();
|
||||
~AudioProperties() override;
|
||||
|
||||
/*!
|
||||
* Returns the length of the file in seconds. The length is rounded down to the nearest whole second.
|
||||
*
|
||||
* \see lengthInMilliseconds()
|
||||
*/
|
||||
virtual int lengthInSeconds() const;
|
||||
int lengthInSeconds() const override;
|
||||
|
||||
/*!
|
||||
* Returns the length of the file in milliseconds.
|
||||
*
|
||||
* \see lengthInSeconds()
|
||||
*/
|
||||
virtual int lengthInMilliseconds() const;
|
||||
int lengthInMilliseconds() const override;
|
||||
|
||||
/*!
|
||||
* Returns the average bit rate of the file in kb/s.
|
||||
*/
|
||||
virtual int bitrate() const;
|
||||
int bitrate() const override;
|
||||
|
||||
/*!
|
||||
* Returns the sample rate in Hz.
|
||||
*/
|
||||
virtual int sampleRate() const;
|
||||
int sampleRate() const override;
|
||||
|
||||
/*!
|
||||
* Returns the number of audio channels.
|
||||
*/
|
||||
virtual int channels() const;
|
||||
int channels() const override;
|
||||
|
||||
/*!
|
||||
* Returns the number of bits per audio sample as read from the FLAC identification header.
|
||||
@@ -99,10 +99,7 @@ class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioPro
|
||||
ByteVector signature() const;
|
||||
|
||||
private:
|
||||
explicit AudioProperties(const AudioProperties &);
|
||||
AudioProperties &operator=(const AudioProperties &);
|
||||
|
||||
void read(const ByteVector &data, long streamLength);
|
||||
void read(const ByteVector &data, long long streamLength);
|
||||
|
||||
class AudioPropertiesPrivate;
|
||||
AudioPropertiesPrivate *d;
|
||||
|
||||
@@ -23,16 +23,16 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <taglib.h>
|
||||
#include <tdebug.h>
|
||||
#include <tstring.h>
|
||||
#include "taglib.h"
|
||||
#include "tdebug.h"
|
||||
#include "tstring.h"
|
||||
#include "flacunknownmetadatablock.h"
|
||||
|
||||
using namespace Strawberry_TagLib::TagLib;
|
||||
|
||||
class FLAC::UnknownMetadataBlock::UnknownMetadataBlockPrivate {
|
||||
public:
|
||||
UnknownMetadataBlockPrivate() : code(0) {}
|
||||
explicit UnknownMetadataBlockPrivate() : code(0) {}
|
||||
|
||||
int code;
|
||||
ByteVector data;
|
||||
|
||||
@@ -38,12 +38,12 @@ namespace FLAC {
|
||||
class TAGLIB_EXPORT UnknownMetadataBlock : public MetadataBlock {
|
||||
public:
|
||||
explicit UnknownMetadataBlock(int code, const ByteVector &data);
|
||||
~UnknownMetadataBlock();
|
||||
~UnknownMetadataBlock() override;
|
||||
|
||||
/*!
|
||||
* Returns the FLAC metadata block type.
|
||||
*/
|
||||
int code() const;
|
||||
int code() const override;
|
||||
|
||||
/*!
|
||||
* Sets the FLAC metadata block type.
|
||||
@@ -63,7 +63,7 @@ class TAGLIB_EXPORT UnknownMetadataBlock : public MetadataBlock {
|
||||
/*!
|
||||
* Render the content of the block.
|
||||
*/
|
||||
ByteVector render() const;
|
||||
ByteVector render() const override;
|
||||
|
||||
private:
|
||||
explicit UnknownMetadataBlock(const MetadataBlock &item);
|
||||
|
||||
Reference in New Issue
Block a user