Adapt most changes from taglib2
This commit is contained in:
61
3rdparty/taglib/dsf/dsffile.cpp
vendored
61
3rdparty/taglib/dsf/dsffile.cpp
vendored
@@ -23,12 +23,14 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tbytevector.h>
|
||||
#include <tdebug.h>
|
||||
#include <id3v2tag.h>
|
||||
#include <tstringlist.h>
|
||||
#include <tpropertymap.h>
|
||||
#include <tagutils.h>
|
||||
#include <memory>
|
||||
|
||||
#include "tbytevector.h"
|
||||
#include "tdebug.h"
|
||||
#include "id3v2tag.h"
|
||||
#include "tstringlist.h"
|
||||
#include "tpropertymap.h"
|
||||
#include "tagutils.h"
|
||||
|
||||
#include "dsffile.h"
|
||||
|
||||
@@ -39,20 +41,13 @@ using namespace Strawberry_TagLib::TagLib;
|
||||
class DSF::File::FilePrivate {
|
||||
public:
|
||||
FilePrivate() : fileSize(0),
|
||||
metadataOffset(0),
|
||||
properties(nullptr),
|
||||
tag(nullptr) {
|
||||
}
|
||||
|
||||
~FilePrivate() {
|
||||
delete properties;
|
||||
delete tag;
|
||||
}
|
||||
metadataOffset(0) {}
|
||||
|
||||
long long fileSize;
|
||||
long long metadataOffset;
|
||||
AudioProperties *properties;
|
||||
ID3v2::Tag *tag;
|
||||
|
||||
std::unique_ptr<AudioProperties> properties;
|
||||
std::unique_ptr<ID3v2::Tag> tag;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -91,7 +86,11 @@ DSF::File::~File() {
|
||||
}
|
||||
|
||||
ID3v2::Tag *DSF::File::tag() const {
|
||||
return d->tag;
|
||||
return d->tag.get();
|
||||
}
|
||||
|
||||
DSF::AudioProperties *DSF::File::audioProperties() const {
|
||||
return d->properties.get();
|
||||
}
|
||||
|
||||
PropertyMap DSF::File::properties() const {
|
||||
@@ -102,10 +101,6 @@ PropertyMap DSF::File::setProperties(const PropertyMap &properties) {
|
||||
return d->tag->setProperties(properties);
|
||||
}
|
||||
|
||||
DSF::AudioProperties *DSF::File::audioProperties() const {
|
||||
return d->properties;
|
||||
}
|
||||
|
||||
bool DSF::File::save() {
|
||||
|
||||
if (readOnly()) {
|
||||
@@ -125,13 +120,13 @@ bool DSF::File::save() {
|
||||
|
||||
// Update the file size
|
||||
if (d->fileSize != newFileSize) {
|
||||
insert(ByteVector::fromLongLong(newFileSize, false), 12, 8);
|
||||
insert(ByteVector::fromUInt64LE(newFileSize), 12, 8);
|
||||
d->fileSize = newFileSize;
|
||||
}
|
||||
|
||||
// Update the metadata offset to 0 since there is no longer a tag
|
||||
if (d->metadataOffset) {
|
||||
insert(ByteVector::fromLongLong(0ULL, false), 20, 8);
|
||||
insert(ByteVector::fromUInt64LE(0ULL), 20, 8);
|
||||
d->metadataOffset = 0;
|
||||
}
|
||||
|
||||
@@ -147,13 +142,13 @@ bool DSF::File::save() {
|
||||
|
||||
// Update the file size
|
||||
if (d->fileSize != newFileSize) {
|
||||
insert(ByteVector::fromLongLong(newFileSize, false), 12, 8);
|
||||
insert(ByteVector::fromUInt64LE(newFileSize), 12, 8);
|
||||
d->fileSize = newFileSize;
|
||||
}
|
||||
|
||||
// Update the metadata offset
|
||||
if (d->metadataOffset != newMetadataOffset) {
|
||||
insert(ByteVector::fromLongLong(newMetadataOffset, false), 20, 8);
|
||||
insert(ByteVector::fromUInt64LE(newMetadataOffset), 20, 8);
|
||||
d->metadataOffset = newMetadataOffset;
|
||||
}
|
||||
|
||||
@@ -183,7 +178,7 @@ void DSF::File::read(bool, AudioProperties::ReadStyle propertiesStyle) {
|
||||
return;
|
||||
}
|
||||
|
||||
long long chunkSize = readBlock(8).toLongLong(false);
|
||||
long long chunkSize = readBlock(8).toInt64LE(0);
|
||||
|
||||
// Integrity check
|
||||
if (28 != chunkSize) {
|
||||
@@ -192,7 +187,7 @@ void DSF::File::read(bool, AudioProperties::ReadStyle propertiesStyle) {
|
||||
return;
|
||||
}
|
||||
|
||||
d->fileSize = readBlock(8).toLongLong(false);
|
||||
d->fileSize = readBlock(8).toInt64LE(0);
|
||||
|
||||
// File is malformed or corrupted
|
||||
if (d->fileSize != length()) {
|
||||
@@ -201,7 +196,7 @@ void DSF::File::read(bool, AudioProperties::ReadStyle propertiesStyle) {
|
||||
return;
|
||||
}
|
||||
|
||||
d->metadataOffset = readBlock(8).toLongLong(false);
|
||||
d->metadataOffset = readBlock(8).toInt64LE(0);
|
||||
|
||||
// File is malformed or corrupted
|
||||
if (d->metadataOffset > d->fileSize) {
|
||||
@@ -218,16 +213,16 @@ void DSF::File::read(bool, AudioProperties::ReadStyle propertiesStyle) {
|
||||
return;
|
||||
}
|
||||
|
||||
chunkSize = readBlock(8).toLongLong(false);
|
||||
chunkSize = readBlock(8).toInt64LE(0);
|
||||
|
||||
d->properties = new AudioProperties(readBlock(chunkSize), propertiesStyle);
|
||||
d->properties.reset(new AudioProperties(readBlock(chunkSize), propertiesStyle));
|
||||
|
||||
// Skip the data chunk
|
||||
|
||||
// A metadata offset of 0 indicates the absence of an ID3v2 tag
|
||||
if (0 == d->metadataOffset)
|
||||
d->tag = new ID3v2::Tag();
|
||||
d->tag.reset(new ID3v2::Tag());
|
||||
else
|
||||
d->tag = new ID3v2::Tag(this, d->metadataOffset);
|
||||
d->tag.reset(new ID3v2::Tag(this, d->metadataOffset));
|
||||
|
||||
}
|
||||
|
||||
14
3rdparty/taglib/dsf/dsffile.h
vendored
14
3rdparty/taglib/dsf/dsffile.h
vendored
@@ -71,35 +71,35 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
|
||||
/*!
|
||||
* Destroys this instance of the File.
|
||||
*/
|
||||
virtual ~File();
|
||||
~File() override;
|
||||
|
||||
/*!
|
||||
* Returns the Tag for this file.
|
||||
*/
|
||||
ID3v2::Tag *tag() const;
|
||||
ID3v2::Tag *tag() const override;
|
||||
|
||||
/*!
|
||||
* Implements the unified property interface -- export function.
|
||||
* This method forwards to ID3v2::Tag::properties().
|
||||
*/
|
||||
PropertyMap properties() const;
|
||||
PropertyMap properties() const override;
|
||||
|
||||
/*!
|
||||
* Implements the unified property interface -- import function.
|
||||
* This method forwards to ID3v2::Tag::setProperties().
|
||||
*/
|
||||
PropertyMap setProperties(const PropertyMap &);
|
||||
PropertyMap setProperties(const PropertyMap &) override;
|
||||
|
||||
/*!
|
||||
* Returns the DSF::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;
|
||||
|
||||
/*!
|
||||
* Saves the file.
|
||||
*/
|
||||
virtual bool save();
|
||||
bool save() override;
|
||||
|
||||
/*!
|
||||
* Returns whether or not the given \a stream can be opened as a DSF file.
|
||||
@@ -110,7 +110,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, AudioProperties::ReadStyle propertiesStyle);
|
||||
|
||||
51
3rdparty/taglib/dsf/dsfproperties.cpp
vendored
51
3rdparty/taglib/dsf/dsfproperties.cpp
vendored
@@ -23,8 +23,8 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tstring.h>
|
||||
#include <tdebug.h>
|
||||
#include "tstring.h"
|
||||
#include "tdebug.h"
|
||||
|
||||
#include "dsfproperties.h"
|
||||
|
||||
@@ -32,16 +32,16 @@ using namespace Strawberry_TagLib::TagLib;
|
||||
|
||||
class DSF::AudioProperties::AudioPropertiesPrivate {
|
||||
public:
|
||||
AudioPropertiesPrivate() : formatVersion(0),
|
||||
formatID(0),
|
||||
channelType(0),
|
||||
channelNum(0),
|
||||
samplingFrequency(0),
|
||||
bitsPerSample(0),
|
||||
sampleCount(0),
|
||||
blockSizePerChannel(0),
|
||||
bitrate(0),
|
||||
length(0) {
|
||||
explicit AudioPropertiesPrivate() : 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
|
||||
@@ -55,16 +55,15 @@ class DSF::AudioProperties::AudioPropertiesPrivate {
|
||||
unsigned int blockSizePerChannel;
|
||||
|
||||
// Computed
|
||||
unsigned int bitrate;
|
||||
unsigned int length;
|
||||
int bitrate;
|
||||
int length;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// public members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DSF::AudioProperties::AudioProperties(const ByteVector &data, ReadStyle style) : Strawberry_TagLib::TagLib::AudioProperties(style) {
|
||||
d = new AudioPropertiesPrivate;
|
||||
DSF::AudioProperties::AudioProperties(const ByteVector &data, ReadStyle) : Strawberry_TagLib::TagLib::AudioProperties(), d(new AudioPropertiesPrivate()) {
|
||||
read(data);
|
||||
}
|
||||
|
||||
@@ -122,15 +121,15 @@ int DSF::AudioProperties::blockSizePerChannel() const {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void DSF::AudioProperties::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->formatVersion = data.toUInt32LE(0);
|
||||
d->formatID = data.toUInt32LE(4);
|
||||
d->channelType = data.toUInt32LE(8);
|
||||
d->channelNum = data.toUInt32LE(12);
|
||||
d->samplingFrequency = data.toUInt32LE(16);
|
||||
d->bitsPerSample = data.toUInt32LE(20);
|
||||
d->sampleCount = data.toInt64LE(24);
|
||||
d->blockSizePerChannel = data.toUInt32LE(32);
|
||||
|
||||
d->bitrate = static_cast<unsigned int>((d->samplingFrequency * d->bitsPerSample * d->channelNum) / 1000.0 + 0.5);
|
||||
d->length = d->samplingFrequency > 0 ? static_cast<unsigned int>(d->sampleCount * 1000.0 / d->samplingFrequency + 0.5) : 0;
|
||||
d->bitrate = static_cast<int>((d->samplingFrequency * d->bitsPerSample * d->channelNum) / 1000.0 + 0.5);
|
||||
d->length = d->samplingFrequency > 0 ? static_cast<int>(d->sampleCount * 1000.0 / d->samplingFrequency + 0.5) : 0;
|
||||
}
|
||||
|
||||
16
3rdparty/taglib/dsf/dsfproperties.h
vendored
16
3rdparty/taglib/dsf/dsfproperties.h
vendored
@@ -45,20 +45,20 @@ class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioPro
|
||||
/*!
|
||||
* Create an instance of DSF::AudioProperties with the data read from the ByteVector \a data.
|
||||
*/
|
||||
explicit AudioProperties(const ByteVector &data, ReadStyle style);
|
||||
explicit AudioProperties(const ByteVector &data, ReadStyle);
|
||||
|
||||
/*!
|
||||
* Destroys this DSF::AudioProperties instance.
|
||||
*/
|
||||
virtual ~AudioProperties();
|
||||
~AudioProperties() override;
|
||||
|
||||
// Reimplementations.
|
||||
|
||||
virtual int lengthInSeconds() const;
|
||||
virtual int lengthInMilliseconds() const;
|
||||
virtual int bitrate() const;
|
||||
virtual int sampleRate() const;
|
||||
virtual int channels() const;
|
||||
int lengthInSeconds() const override;
|
||||
int lengthInMilliseconds() const override;
|
||||
int bitrate() const override;
|
||||
int sampleRate() const override;
|
||||
int channels() const override;
|
||||
|
||||
int formatVersion() const;
|
||||
int formatID() const;
|
||||
@@ -79,7 +79,7 @@ class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioPro
|
||||
int blockSizePerChannel() const;
|
||||
|
||||
private:
|
||||
explicit AudioProperties(const AudioProperties&);
|
||||
AudioProperties(const AudioProperties&);
|
||||
AudioProperties &operator=(const AudioProperties&);
|
||||
|
||||
void read(const ByteVector &data);
|
||||
|
||||
Reference in New Issue
Block a user