Adapt most changes from taglib2
This commit is contained in:
parent
08882639e0
commit
5f71a558b9
4
.github/workflows/ccpp.yml
vendored
4
.github/workflows/ccpp.yml
vendored
@ -1133,7 +1133,7 @@ jobs:
|
||||
GST_SCANNER_PATH: /usr/local/opt/gstreamer/libexec/gstreamer-1.0/gst-plugin-scanner
|
||||
GST_PLUGIN_PATH: /usr/local/lib/gstreamer-1.0
|
||||
working-directory: build
|
||||
run: cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DUSE_BUNDLE=ON -DUSE_SYSTEM_TAGLIB=OFF
|
||||
run: cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DUSE_BUNDLE=ON
|
||||
- name: Build
|
||||
working-directory: build
|
||||
shell: bash
|
||||
@ -1180,8 +1180,6 @@ jobs:
|
||||
-DENABLE_IMOBILEDEVICE=OFF
|
||||
-DENABLE_LIBMTP=OFF
|
||||
-DENABLE_XINE=OFF
|
||||
-DUSE_SYSTEM_SINGLEAPPLICATION=OFF
|
||||
-DUSE_SYSTEM_TAGLIB=OFF
|
||||
-DProtobuf_PROTOC_EXECUTABLE=/usr/src/strawberry-mxe/usr/x86_64-pc-linux-gnu/bin/protoc
|
||||
|
||||
- name: Run Make
|
||||
|
@ -33,7 +33,7 @@ before_install:
|
||||
fi
|
||||
before_script:
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker exec build cmake -Hstrawberry -Bbuild ; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then mkdir build; cd build; cmake .. -DUSE_BUNDLE=ON -DUSE_SYSTEM_TAGLIB=OFF ; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then mkdir build; cd build; cmake .. -DUSE_BUNDLE=ON ; fi
|
||||
script:
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker exec build make -C build -j8 ; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
|
||||
|
19
3rdparty/taglib/CMakeLists.txt
vendored
19
3rdparty/taglib/CMakeLists.txt
vendored
@ -8,17 +8,9 @@ math(EXPR TAGLIB_SOVERSION_MAJOR "${TAGLIB_SOVERSION_CURRENT} - ${TAGLIB_SOVERSI
|
||||
math(EXPR TAGLIB_SOVERSION_MINOR "${TAGLIB_SOVERSION_AGE}")
|
||||
math(EXPR TAGLIB_SOVERSION_PATCH "${TAGLIB_SOVERSION_REVISION}")
|
||||
|
||||
include(TestBigEndian)
|
||||
test_big_endian(IS_BIG_ENDIAN)
|
||||
|
||||
if(NOT IS_BIG_ENDIAN)
|
||||
add_definitions(-DSYSTEM_BYTEORDER=1)
|
||||
else()
|
||||
add_definitions(-DSYSTEM_BYTEORDER=2)
|
||||
endif()
|
||||
|
||||
include(ConfigureChecks.cmake)
|
||||
configure_file(config.h.cmake "${CMAKE_CURRENT_BINARY_DIR}/config.h")
|
||||
set(TESTS_DIR "${CMAKE_SOURCE_DIR}/tests/taglib/")
|
||||
configure_file(taglib-config.h.cmake "${CMAKE_CURRENT_BINARY_DIR}/taglib-config.h")
|
||||
|
||||
add_definitions(-DHAVE_CONFIG_H)
|
||||
add_definitions(-DTAGLIB_STATIC)
|
||||
@ -33,6 +25,7 @@ set(tag_HDRS
|
||||
toolkit/tlist.h
|
||||
toolkit/tlist.tcc
|
||||
toolkit/tstringlist.h
|
||||
toolkit/tstringhandler.h
|
||||
toolkit/tbytevector.h
|
||||
toolkit/tbytevectorlist.h
|
||||
toolkit/tbytevectorstream.h
|
||||
@ -41,6 +34,8 @@ set(tag_HDRS
|
||||
toolkit/tfilestream.h
|
||||
toolkit/tmap.h
|
||||
toolkit/tmap.tcc
|
||||
toolkit/tpicture.h
|
||||
toolkit/tpicturemap.h
|
||||
toolkit/tpropertymap.h
|
||||
toolkit/trefcounter.h
|
||||
toolkit/tdebuglistener.h
|
||||
@ -300,8 +295,10 @@ set(dsdiff_SRCS
|
||||
)
|
||||
|
||||
set(toolkit_SRCS
|
||||
toolkit/taglib.cpp
|
||||
toolkit/tstring.cpp
|
||||
toolkit/tstringlist.cpp
|
||||
toolkit/tstringhandler.cpp
|
||||
toolkit/tbytevector.cpp
|
||||
toolkit/tbytevectorlist.cpp
|
||||
toolkit/tbytevectorstream.cpp
|
||||
@ -309,6 +306,8 @@ set(toolkit_SRCS
|
||||
toolkit/tfile.cpp
|
||||
toolkit/tfilestream.cpp
|
||||
toolkit/tdebug.cpp
|
||||
toolkit/tpicture.cpp
|
||||
toolkit/tpicturemap.cpp
|
||||
toolkit/tpropertymap.cpp
|
||||
toolkit/trefcounter.cpp
|
||||
toolkit/tdebuglistener.cpp
|
||||
|
67
3rdparty/taglib/ape/apefile.cpp
vendored
67
3rdparty/taglib/ape/apefile.cpp
vendored
@ -31,14 +31,16 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tbytevector.h>
|
||||
#include <tstring.h>
|
||||
#include <tdebug.h>
|
||||
#include <tagunion.h>
|
||||
#include <id3v1tag.h>
|
||||
#include <id3v2header.h>
|
||||
#include <tpropertymap.h>
|
||||
#include <tagutils.h>
|
||||
#include <memory>
|
||||
|
||||
#include "tbytevector.h"
|
||||
#include "tstring.h"
|
||||
#include "tdebug.h"
|
||||
#include "tagunion.h"
|
||||
#include "id3v1tag.h"
|
||||
#include "id3v2header.h"
|
||||
#include "tpropertymap.h"
|
||||
#include "tagutils.h"
|
||||
|
||||
#include "apefile.h"
|
||||
#include "apetag.h"
|
||||
@ -56,42 +58,33 @@ class APE::File::FilePrivate {
|
||||
FilePrivate() : APELocation(-1),
|
||||
APESize(0),
|
||||
ID3v1Location(-1),
|
||||
ID3v2Header(nullptr),
|
||||
ID3v2Location(-1),
|
||||
ID3v2Size(0),
|
||||
properties(nullptr) {}
|
||||
ID3v2Size(0) {}
|
||||
|
||||
~FilePrivate() {
|
||||
delete ID3v2Header;
|
||||
delete properties;
|
||||
}
|
||||
long long APELocation;
|
||||
long long APESize;
|
||||
|
||||
long APELocation;
|
||||
long APESize;
|
||||
long long ID3v1Location;
|
||||
|
||||
long ID3v1Location;
|
||||
std::unique_ptr<ID3v2::Header> ID3v2Header;
|
||||
long long ID3v2Location;
|
||||
long long ID3v2Size;
|
||||
|
||||
ID3v2::Header *ID3v2Header;
|
||||
long ID3v2Location;
|
||||
long ID3v2Size;
|
||||
DoubleTagUnion tag;
|
||||
|
||||
TagUnion tag;
|
||||
|
||||
AudioProperties *properties;
|
||||
std::unique_ptr<AudioProperties> properties;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// static members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool APE::File::isSupported(IOStream *) {
|
||||
bool APE::File::isSupported(IOStream *stream) {
|
||||
// An APE file has an ID "MAC " somewhere. An ID3v2 tag may precede.
|
||||
|
||||
// FIXME:
|
||||
//const ByteVector buffer = Utils::readHeader(stream, bufferSize(), true);
|
||||
//return (buffer.find("MAC ") >= 0);
|
||||
const ByteVector buffer = Utils::readHeader(stream, bufferSize(), true);
|
||||
return (buffer.find("MAC ") != ByteVector::npos());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -120,14 +113,6 @@ Strawberry_TagLib::TagLib::Tag *APE::File::tag() const {
|
||||
return &d->tag;
|
||||
}
|
||||
|
||||
PropertyMap APE::File::properties() const {
|
||||
return d->tag.properties();
|
||||
}
|
||||
|
||||
void APE::File::removeUnsupportedProperties(const StringList &properties) {
|
||||
d->tag.removeUnsupportedProperties(properties);
|
||||
}
|
||||
|
||||
PropertyMap APE::File::setProperties(const PropertyMap &properties) {
|
||||
|
||||
if (ID3v1Tag())
|
||||
@ -138,7 +123,7 @@ PropertyMap APE::File::setProperties(const PropertyMap &properties) {
|
||||
}
|
||||
|
||||
APE::AudioProperties *APE::File::audioProperties() const {
|
||||
return d->properties;
|
||||
return d->properties.get();
|
||||
}
|
||||
|
||||
bool APE::File::save() {
|
||||
@ -255,7 +240,7 @@ void APE::File::read(bool readProperties) {
|
||||
|
||||
if (d->ID3v2Location >= 0) {
|
||||
seek(d->ID3v2Location);
|
||||
d->ID3v2Header = new ID3v2::Header(readBlock(ID3v2::Header::size()));
|
||||
d->ID3v2Header.reset(new ID3v2::Header(readBlock(ID3v2::Header::size())));
|
||||
d->ID3v2Size = d->ID3v2Header->completeTagSize();
|
||||
}
|
||||
|
||||
@ -283,7 +268,7 @@ void APE::File::read(bool readProperties) {
|
||||
|
||||
if (readProperties) {
|
||||
|
||||
long streamLength;
|
||||
long long streamLength;
|
||||
|
||||
if (d->APELocation >= 0)
|
||||
streamLength = d->APELocation;
|
||||
@ -300,7 +285,7 @@ void APE::File::read(bool readProperties) {
|
||||
seek(0);
|
||||
}
|
||||
|
||||
d->properties = new AudioProperties(this, streamLength);
|
||||
d->properties.reset(new AudioProperties(this, streamLength));
|
||||
}
|
||||
|
||||
}
|
||||
|
23
3rdparty/taglib/ape/apefile.h
vendored
23
3rdparty/taglib/ape/apefile.h
vendored
@ -107,36 +107,25 @@ 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. This will be an APE tag, an ID3v1 tag or a combination of the two.
|
||||
*/
|
||||
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;
|
||||
|
||||
/*!
|
||||
* Removes unsupported properties. Forwards to the actual Tag's removeUnsupportedProperties() function.
|
||||
*/
|
||||
void removeUnsupportedProperties(const StringList &properties);
|
||||
Strawberry_TagLib::TagLib::Tag *tag() const override;
|
||||
|
||||
/*!
|
||||
* 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&) override;
|
||||
|
||||
/*!
|
||||
* Returns the APE::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.
|
||||
@ -144,7 +133,7 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::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();
|
||||
bool save() override;
|
||||
|
||||
/*!
|
||||
* Returns a pointer to the ID3v1 tag of the file.
|
||||
@ -210,7 +199,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);
|
||||
|
22
3rdparty/taglib/ape/apefooter.cpp
vendored
22
3rdparty/taglib/ape/apefooter.cpp
vendored
@ -27,8 +27,8 @@
|
||||
#include <iostream>
|
||||
#include <bitset>
|
||||
|
||||
#include <tstring.h>
|
||||
#include <tdebug.h>
|
||||
#include "tstring.h"
|
||||
#include "tdebug.h"
|
||||
|
||||
#include "apefooter.h"
|
||||
|
||||
@ -155,19 +155,19 @@ void APE::Footer::parse(const ByteVector &data) {
|
||||
|
||||
// Read the version number
|
||||
|
||||
d->version = data.toUInt(8, false);
|
||||
d->version = data.toUInt32LE(8);
|
||||
|
||||
// Read the tag size
|
||||
|
||||
d->tagSize = data.toUInt(12, false);
|
||||
d->tagSize = data.toUInt32LE(12);
|
||||
|
||||
// Read the item count
|
||||
|
||||
d->itemCount = data.toUInt(16, false);
|
||||
d->itemCount = data.toUInt32LE(16);
|
||||
|
||||
// Read the flags
|
||||
|
||||
std::bitset<32> flags(TAGLIB_CONSTRUCT_BITSET(data.toUInt(20, false)));
|
||||
std::bitset<32> flags(TAGLIB_CONSTRUCT_BITSET(data.toUInt32LE(20)));
|
||||
|
||||
d->headerPresent = flags[31];
|
||||
d->footerPresent = !flags[30];
|
||||
@ -186,15 +186,15 @@ ByteVector APE::Footer::render(bool isHeader) const {
|
||||
// add the version number -- we always render a 2.000 tag regardless of what
|
||||
// the tag originally was.
|
||||
|
||||
v.append(ByteVector::fromUInt(2000, false));
|
||||
v.append(ByteVector::fromUInt32LE(2000));
|
||||
|
||||
// add the tag size
|
||||
|
||||
v.append(ByteVector::fromUInt(d->tagSize, false));
|
||||
v.append(ByteVector::fromUInt32LE(d->tagSize));
|
||||
|
||||
// add the item count
|
||||
|
||||
v.append(ByteVector::fromUInt(d->itemCount, false));
|
||||
v.append(ByteVector::fromUInt32LE(d->itemCount));
|
||||
|
||||
// render and add the flags
|
||||
|
||||
@ -204,11 +204,11 @@ ByteVector APE::Footer::render(bool isHeader) const {
|
||||
flags[30] = false; // footer is always present
|
||||
flags[29] = isHeader;
|
||||
|
||||
v.append(ByteVector::fromUInt(flags.to_ulong(), false));
|
||||
v.append(ByteVector::fromUInt32LE(flags.to_ulong()));
|
||||
|
||||
// add the reserved 64bit
|
||||
|
||||
v.append(ByteVector::fromLongLong(0));
|
||||
v.append(ByteVector::fromUInt64BE(0));
|
||||
|
||||
return v;
|
||||
|
||||
|
2
3rdparty/taglib/ape/apefooter.h
vendored
2
3rdparty/taglib/ape/apefooter.h
vendored
@ -161,7 +161,7 @@ class TAGLIB_EXPORT Footer {
|
||||
ByteVector render(bool isHeader) const;
|
||||
|
||||
private:
|
||||
explicit Footer(const Footer &);
|
||||
Footer(const Footer &);
|
||||
Footer &operator=(const Footer &);
|
||||
|
||||
class FooterPrivate;
|
||||
|
158
3rdparty/taglib/ape/apeitem.cpp
vendored
158
3rdparty/taglib/ape/apeitem.cpp
vendored
@ -23,17 +23,18 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tbytevectorlist.h>
|
||||
#include <tdebug.h>
|
||||
#include <memory>
|
||||
|
||||
#include "tbytevectorlist.h"
|
||||
#include "tdebug.h"
|
||||
|
||||
#include "apeitem.h"
|
||||
|
||||
using namespace Strawberry_TagLib::TagLib;
|
||||
using namespace APE;
|
||||
|
||||
class APE::Item::ItemPrivate {
|
||||
public:
|
||||
ItemPrivate() : type(Text), readOnly(false) {}
|
||||
struct ItemData {
|
||||
ItemData() : type(Item::Text), readOnly(false) {}
|
||||
|
||||
Item::ItemTypes type;
|
||||
String key;
|
||||
@ -42,26 +43,37 @@ class APE::Item::ItemPrivate {
|
||||
bool readOnly;
|
||||
};
|
||||
|
||||
class APE::Item::ItemPrivate {
|
||||
public:
|
||||
ItemPrivate() : data(new ItemData()) {}
|
||||
|
||||
std::shared_ptr<ItemData> data;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// public members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
APE::Item::Item() : d(new ItemPrivate()) {}
|
||||
|
||||
APE::Item::Item(const String &key, const String &value) : d(new ItemPrivate()) {
|
||||
d->data->key = key;
|
||||
d->data->text.append(value);
|
||||
}
|
||||
|
||||
APE::Item::Item(const String &key, const StringList &values) : d(new ItemPrivate()) {
|
||||
d->key = key;
|
||||
d->text = values;
|
||||
d->data->key = key;
|
||||
d->data->text = values;
|
||||
}
|
||||
|
||||
APE::Item::Item(const String &key, const ByteVector &value, bool binary) : d(new ItemPrivate()) {
|
||||
|
||||
d->key = key;
|
||||
d->data->key = key;
|
||||
if (binary) {
|
||||
d->type = Binary;
|
||||
d->value = value;
|
||||
d->data->type = Binary;
|
||||
d->data->value = value;
|
||||
}
|
||||
else {
|
||||
d->text.append(value);
|
||||
d->data->text.append(value);
|
||||
}
|
||||
|
||||
}
|
||||
@ -88,126 +100,109 @@ void APE::Item::swap(Item &item) {
|
||||
}
|
||||
|
||||
void APE::Item::setReadOnly(bool readOnly) {
|
||||
d->readOnly = readOnly;
|
||||
d->data->readOnly = readOnly;
|
||||
}
|
||||
|
||||
bool APE::Item::isReadOnly() const {
|
||||
return d->readOnly;
|
||||
return d->data->readOnly;
|
||||
}
|
||||
|
||||
void APE::Item::setType(APE::Item::ItemTypes type) {
|
||||
d->type = type;
|
||||
void APE::Item::setType(APE::Item::ItemTypes val) {
|
||||
d->data->type = val;
|
||||
}
|
||||
|
||||
APE::Item::ItemTypes APE::Item::type() const {
|
||||
return d->type;
|
||||
return d->data->type;
|
||||
}
|
||||
|
||||
String APE::Item::key() const {
|
||||
return d->key;
|
||||
return d->data->key;
|
||||
}
|
||||
|
||||
ByteVector APE::Item::binaryData() const {
|
||||
return d->value;
|
||||
return d->data->value;
|
||||
}
|
||||
|
||||
void APE::Item::setBinaryData(const ByteVector &value) {
|
||||
|
||||
d->type = Binary;
|
||||
d->value = value;
|
||||
d->text.clear();
|
||||
|
||||
d->data->type = Binary;
|
||||
d->data->value = value;
|
||||
d->data->text.clear();
|
||||
}
|
||||
|
||||
void APE::Item::setKey(const String &key) {
|
||||
d->key = key;
|
||||
d->data->key = key;
|
||||
}
|
||||
|
||||
void APE::Item::setValue(const String &value) {
|
||||
|
||||
d->type = Text;
|
||||
d->text = value;
|
||||
d->value.clear();
|
||||
|
||||
d->data->type = Text;
|
||||
d->data->text = value;
|
||||
d->data->value.clear();
|
||||
}
|
||||
|
||||
void APE::Item::setValues(const StringList &value) {
|
||||
|
||||
d->type = Text;
|
||||
d->text = value;
|
||||
d->value.clear();
|
||||
|
||||
d->data->type = Text;
|
||||
d->data->text = value;
|
||||
d->data->value.clear();
|
||||
}
|
||||
|
||||
void APE::Item::appendValue(const String &value) {
|
||||
|
||||
d->type = Text;
|
||||
d->text.append(value);
|
||||
d->value.clear();
|
||||
|
||||
d->data->type = Text;
|
||||
d->data->text.append(value);
|
||||
d->data->value.clear();
|
||||
}
|
||||
|
||||
void APE::Item::appendValues(const StringList &values) {
|
||||
|
||||
d->type = Text;
|
||||
d->text.append(values);
|
||||
d->value.clear();
|
||||
|
||||
d->data->type = Text;
|
||||
d->data->text.append(values);
|
||||
d->data->value.clear();
|
||||
}
|
||||
|
||||
int APE::Item::size() const {
|
||||
|
||||
int result = 8 + d->key.size() + 1;
|
||||
switch (d->type) {
|
||||
size_t result = 8 + d->data->key.size() + 1;
|
||||
switch (d->data->type) {
|
||||
case Text:
|
||||
if (!d->text.isEmpty()) {
|
||||
StringList::ConstIterator it = d->text.begin();
|
||||
if (!d->data->text.isEmpty()) {
|
||||
StringList::ConstIterator it = d->data->text.begin();
|
||||
|
||||
result += it->data(String::UTF8).size();
|
||||
it++;
|
||||
for (; it != d->text.end(); ++it)
|
||||
for (; it != d->data->text.end(); ++it)
|
||||
result += 1 + it->data(String::UTF8).size();
|
||||
}
|
||||
break;
|
||||
|
||||
case Binary:
|
||||
case Locator:
|
||||
result += d->value.size();
|
||||
result += d->data->value.size();
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
StringList APE::Item::toStringList() const {
|
||||
return d->text;
|
||||
}
|
||||
|
||||
StringList APE::Item::values() const {
|
||||
return d->text;
|
||||
return d->data->text;
|
||||
}
|
||||
|
||||
String APE::Item::toString() const {
|
||||
|
||||
if (d->type == Text && !isEmpty())
|
||||
return d->text.front();
|
||||
if (d->data->type == Text && !isEmpty())
|
||||
return d->data->text.front();
|
||||
else
|
||||
return String();
|
||||
|
||||
}
|
||||
|
||||
bool APE::Item::isEmpty() const {
|
||||
|
||||
switch (d->type) {
|
||||
switch (d->data->type) {
|
||||
case Text:
|
||||
if (d->text.isEmpty())
|
||||
if (d->data->text.isEmpty())
|
||||
return true;
|
||||
if (d->text.size() == 1 && d->text.front().isEmpty())
|
||||
if (d->data->text.size() == 1 && d->data->text.front().isEmpty())
|
||||
return true;
|
||||
return false;
|
||||
case Binary:
|
||||
case Locator:
|
||||
return d->value.isEmpty();
|
||||
return d->data->value.isEmpty();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@ -223,52 +218,51 @@ void APE::Item::parse(const ByteVector &data) {
|
||||
return;
|
||||
}
|
||||
|
||||
const unsigned int valueLength = data.toUInt(0, false);
|
||||
const unsigned int flags = data.toUInt(4, false);
|
||||
const unsigned int valueLength = data.toUInt32LE(0);
|
||||
const unsigned int flags = data.toUInt32LE(4);
|
||||
|
||||
// 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.
|
||||
|
||||
d->key = String(&data[8], String::Latin1);
|
||||
d->data->key = String(&data[8], String::Latin1);
|
||||
|
||||
const ByteVector value = data.mid(8 + d->key.size() + 1, valueLength);
|
||||
const ByteVector value = data.mid(8 + d->data->key.size() + 1, valueLength);
|
||||
|
||||
setReadOnly(flags & 1);
|
||||
setType(ItemTypes((flags >> 1) & 3));
|
||||
|
||||
if (Text == d->type)
|
||||
d->text = StringList(ByteVectorList::split(value, '\0'), String::UTF8);
|
||||
if (Text == d->data->type)
|
||||
d->data->text = StringList(ByteVectorList::split(value, '\0'), String::UTF8);
|
||||
else
|
||||
d->value = value;
|
||||
|
||||
d->data->value = value;
|
||||
}
|
||||
|
||||
ByteVector APE::Item::render() const {
|
||||
|
||||
ByteVector data;
|
||||
unsigned int flags = ((d->readOnly) ? 1 : 0) | (d->type << 1);
|
||||
unsigned int flags = ((d->data->readOnly) ? 1 : 0) | (d->data->type << 1);
|
||||
ByteVector value;
|
||||
|
||||
if (isEmpty())
|
||||
return data;
|
||||
|
||||
if (d->type == Text) {
|
||||
StringList::ConstIterator it = d->text.begin();
|
||||
if (d->data->type == Text) {
|
||||
StringList::ConstIterator it = d->data->text.begin();
|
||||
|
||||
value.append(it->data(String::UTF8));
|
||||
it++;
|
||||
for (; it != d->text.end(); ++it) {
|
||||
for (; it != d->data->text.end(); ++it) {
|
||||
value.append('\0');
|
||||
value.append(it->data(String::UTF8));
|
||||
}
|
||||
d->value = value;
|
||||
d->data->value = value;
|
||||
}
|
||||
else
|
||||
value.append(d->value);
|
||||
value.append(d->data->value);
|
||||
|
||||
data.append(ByteVector::fromUInt(value.size(), false));
|
||||
data.append(ByteVector::fromUInt(flags, false));
|
||||
data.append(d->key.data(String::Latin1));
|
||||
data.append(ByteVector::fromUInt32LE(value.size()));
|
||||
data.append(ByteVector::fromUInt32LE(flags));
|
||||
data.append(d->data->key.data(String::Latin1));
|
||||
data.append(ByteVector('\0'));
|
||||
data.append(value);
|
||||
|
||||
|
8
3rdparty/taglib/ape/apeitem.h
vendored
8
3rdparty/taglib/ape/apeitem.h
vendored
@ -57,6 +57,11 @@ class TAGLIB_EXPORT Item {
|
||||
*/
|
||||
explicit Item();
|
||||
|
||||
/*!
|
||||
* Constructs a text item with \a key and \a values.
|
||||
*/
|
||||
explicit Item(const String &key, const String &values);
|
||||
|
||||
/*!
|
||||
* Constructs a text item with \a key and \a values.
|
||||
*/
|
||||
@ -71,7 +76,7 @@ class TAGLIB_EXPORT Item {
|
||||
/*!
|
||||
* Construct an item as a copy of \a item.
|
||||
*/
|
||||
explicit Item(const Item &item);
|
||||
Item(const Item &item);
|
||||
|
||||
/*!
|
||||
* Destroys the item.
|
||||
@ -148,7 +153,6 @@ class TAGLIB_EXPORT Item {
|
||||
* If the data type is not \a Text, always returns an empty String.
|
||||
*/
|
||||
String toString() const;
|
||||
StringList toStringList() const;
|
||||
|
||||
/*!
|
||||
* Returns the list of text values. If the data type is not \a Text, always returns an empty StringList.
|
||||
|
54
3rdparty/taglib/ape/apeproperties.cpp
vendored
54
3rdparty/taglib/ape/apeproperties.cpp
vendored
@ -27,9 +27,9 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tstring.h>
|
||||
#include <tdebug.h>
|
||||
#include <bitset>
|
||||
#include "tstring.h"
|
||||
#include "tdebug.h"
|
||||
|
||||
#include "id3v2tag.h"
|
||||
#include "apeproperties.h"
|
||||
#include "apefile.h"
|
||||
@ -40,13 +40,13 @@ using namespace Strawberry_TagLib::TagLib;
|
||||
|
||||
class APE::AudioProperties::AudioPropertiesPrivate {
|
||||
public:
|
||||
AudioPropertiesPrivate() : length(0),
|
||||
bitrate(0),
|
||||
sampleRate(0),
|
||||
channels(0),
|
||||
version(0),
|
||||
bitsPerSample(0),
|
||||
sampleFrames(0) {}
|
||||
explicit AudioPropertiesPrivate() : length(0),
|
||||
bitrate(0),
|
||||
sampleRate(0),
|
||||
channels(0),
|
||||
version(0),
|
||||
bitsPerSample(0),
|
||||
sampleFrames(0) {}
|
||||
|
||||
int length;
|
||||
int bitrate;
|
||||
@ -61,7 +61,7 @@ class APE::AudioProperties::AudioPropertiesPrivate {
|
||||
// public members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
APE::AudioProperties::AudioProperties(File *file, long streamLength, ReadStyle style) : Strawberry_TagLib::TagLib::AudioProperties(style), d(new AudioPropertiesPrivate()) {
|
||||
APE::AudioProperties::AudioProperties(File *file, long long streamLength, ReadStyle) : Strawberry_TagLib::TagLib::AudioProperties(), d(new AudioPropertiesPrivate()) {
|
||||
read(file, streamLength);
|
||||
}
|
||||
|
||||
@ -110,14 +110,14 @@ int headerVersion(const ByteVector &header) {
|
||||
if (header.size() < 6 || !header.startsWith("MAC "))
|
||||
return -1;
|
||||
|
||||
return header.toUShort(4, false);
|
||||
return header.toUInt16LE(4);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void APE::AudioProperties::read(File *file, long streamLength) {
|
||||
void APE::AudioProperties::read(File *file, long long streamLength) {
|
||||
|
||||
// First, we assume that the file pointer is set at the first descriptor.
|
||||
long offset = file->tell();
|
||||
long long offset = file->tell();
|
||||
int version = headerVersion(file->readBlock(6));
|
||||
|
||||
// Next, we look for the descriptor.
|
||||
@ -157,7 +157,7 @@ void APE::AudioProperties::analyzeCurrent(File *file) {
|
||||
return;
|
||||
}
|
||||
|
||||
const unsigned int descriptorBytes = descriptor.toUInt(0, false);
|
||||
const unsigned int descriptorBytes = descriptor.toUInt32LE(0);
|
||||
|
||||
if ((descriptorBytes - 52) > 0)
|
||||
file->seek(descriptorBytes - 52, File::Current);
|
||||
@ -170,16 +170,16 @@ void APE::AudioProperties::analyzeCurrent(File *file) {
|
||||
}
|
||||
|
||||
// Get the APE info
|
||||
d->channels = header.toShort(18, false);
|
||||
d->sampleRate = header.toUInt(20, false);
|
||||
d->bitsPerSample = header.toShort(16, false);
|
||||
d->channels = header.toUInt16LE(18);
|
||||
d->sampleRate = header.toUInt32LE(20);
|
||||
d->bitsPerSample = header.toUInt16LE(16);
|
||||
|
||||
const unsigned int totalFrames = header.toUInt(12, false);
|
||||
const unsigned int totalFrames = header.toUInt32LE(12);
|
||||
if (totalFrames == 0)
|
||||
return;
|
||||
|
||||
const unsigned int blocksPerFrame = header.toUInt(4, false);
|
||||
const unsigned int finalFrameBlocks = header.toUInt(8, false);
|
||||
const unsigned int blocksPerFrame = header.toUInt32LE(4);
|
||||
const unsigned int finalFrameBlocks = header.toUInt32LE(8);
|
||||
d->sampleFrames = (totalFrames - 1) * blocksPerFrame + finalFrameBlocks;
|
||||
|
||||
}
|
||||
@ -192,13 +192,13 @@ void APE::AudioProperties::analyzeOld(File *file) {
|
||||
return;
|
||||
}
|
||||
|
||||
const unsigned int totalFrames = header.toUInt(18, false);
|
||||
const unsigned int totalFrames = header.toUInt32LE(18);
|
||||
|
||||
// Fail on 0 length APE files (catches non-finalized APE files)
|
||||
if (totalFrames == 0)
|
||||
return;
|
||||
|
||||
const short compressionLevel = header.toShort(0, false);
|
||||
const short compressionLevel = header.toUInt32LE(0);
|
||||
unsigned int blocksPerFrame;
|
||||
if (d->version >= 3950)
|
||||
blocksPerFrame = 73728 * 4;
|
||||
@ -208,10 +208,10 @@ void APE::AudioProperties::analyzeOld(File *file) {
|
||||
blocksPerFrame = 9216;
|
||||
|
||||
// Get the APE info
|
||||
d->channels = header.toShort(4, false);
|
||||
d->sampleRate = header.toUInt(6, false);
|
||||
d->channels = header.toUInt16LE(4);
|
||||
d->sampleRate = header.toUInt32LE(6);
|
||||
|
||||
const unsigned int finalFrameBlocks = header.toUInt(22, false);
|
||||
const unsigned int finalFrameBlocks = header.toUInt32LE(22);
|
||||
d->sampleFrames = (totalFrames - 1) * blocksPerFrame + finalFrameBlocks;
|
||||
|
||||
// Get the bit depth from the RIFF-fmt chunk.
|
||||
@ -222,6 +222,6 @@ void APE::AudioProperties::analyzeOld(File *file) {
|
||||
return;
|
||||
}
|
||||
|
||||
d->bitsPerSample = fmt.toShort(26, false);
|
||||
d->bitsPerSample = fmt.toUInt16LE(26);
|
||||
|
||||
}
|
||||
|
19
3rdparty/taglib/ape/apeproperties.h
vendored
19
3rdparty/taglib/ape/apeproperties.h
vendored
@ -51,41 +51,41 @@ class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioPro
|
||||
/*!
|
||||
* Create an instance of APE::AudioProperties with the data read from the APE::File \a file.
|
||||
*/
|
||||
explicit AudioProperties(File *file, long streamLength, ReadStyle style = Average);
|
||||
explicit AudioProperties(File *file, long long streamLength, ReadStyle style = Average);
|
||||
|
||||
/*!
|
||||
* Destroys this APE::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.
|
||||
@ -103,10 +103,7 @@ class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioPro
|
||||
int version() const;
|
||||
|
||||
private:
|
||||
explicit AudioProperties(const AudioProperties &);
|
||||
AudioProperties &operator=(const AudioProperties &);
|
||||
|
||||
void read(File *file, long streamLength);
|
||||
void read(File *file, long long streamLength);
|
||||
|
||||
void analyzeCurrent(File *file);
|
||||
void analyzeOld(File *file);
|
||||
|
121
3rdparty/taglib/ape/apetag.cpp
vendored
121
3rdparty/taglib/ape/apetag.cpp
vendored
@ -31,12 +31,13 @@
|
||||
# define WANT_CLASS_INSTANTIATION_OF_MAP (1)
|
||||
#endif
|
||||
|
||||
#include <tfile.h>
|
||||
#include <tstring.h>
|
||||
#include <tmap.h>
|
||||
#include <tpropertymap.h>
|
||||
#include <tdebug.h>
|
||||
#include <tutils.h>
|
||||
#include "tfile.h"
|
||||
#include "tstring.h"
|
||||
#include "tmap.h"
|
||||
#include "tpicturemap.h"
|
||||
#include "tpropertymap.h"
|
||||
#include "tdebug.h"
|
||||
#include "tutils.h"
|
||||
|
||||
#include "apetag.h"
|
||||
#include "apefooter.h"
|
||||
@ -76,7 +77,7 @@ class APE::Tag::TagPrivate {
|
||||
TagPrivate() : file(nullptr), footerLocation(0) {}
|
||||
|
||||
File *file;
|
||||
long footerLocation;
|
||||
long long footerLocation;
|
||||
|
||||
Footer footer;
|
||||
ItemListMap itemListMap;
|
||||
@ -88,7 +89,7 @@ class APE::Tag::TagPrivate {
|
||||
|
||||
APE::Tag::Tag() : d(new TagPrivate()) {}
|
||||
|
||||
APE::Tag::Tag(Strawberry_TagLib::TagLib::File *file, long footerLocation) : d(new TagPrivate()) {
|
||||
APE::Tag::Tag(Strawberry_TagLib::TagLib::File *file, long long footerLocation) : d(new TagPrivate()) {
|
||||
|
||||
d->file = file;
|
||||
d->footerLocation = footerLocation;
|
||||
@ -160,6 +161,43 @@ unsigned int APE::Tag::track() const {
|
||||
|
||||
}
|
||||
|
||||
Strawberry_TagLib::TagLib::PictureMap APE::Tag::pictures() const {
|
||||
|
||||
PictureMap map;
|
||||
if (d->itemListMap.contains(FRONT_COVER)) {
|
||||
Item front = d->itemListMap[FRONT_COVER];
|
||||
if (Item::Binary == front.type()) {
|
||||
ByteVector picture = front.binaryData();
|
||||
const size_t index = picture.find('\0');
|
||||
if (index < picture.size()) {
|
||||
ByteVector desc = picture.mid(0, index + 1);
|
||||
String mime = "image/jpeg";
|
||||
ByteVector data = picture.mid(index + 1);
|
||||
Picture p(data, Picture::FrontCover, mime, desc);
|
||||
map.insert(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (d->itemListMap.contains(BACK_COVER)) {
|
||||
Item back = d->itemListMap[BACK_COVER];
|
||||
if (Item::Binary == back.type()) {
|
||||
ByteVector picture = back.binaryData();
|
||||
const size_t index = picture.find('\0');
|
||||
if (index < picture.size()) {
|
||||
ByteVector desc = picture.mid(0, index + 1);
|
||||
String mime = "image/jpeg";
|
||||
ByteVector data = picture.mid(index + 1);
|
||||
Picture p(data, Picture::BackCover, mime, desc);
|
||||
map.insert(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return PictureMap(map);
|
||||
|
||||
}
|
||||
|
||||
void APE::Tag::setTitle(const String &s) {
|
||||
addValue("TITLE", s, true);
|
||||
}
|
||||
@ -181,17 +219,72 @@ void APE::Tag::setGenre(const String &s) {
|
||||
}
|
||||
|
||||
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)
|
||||
removeItem("TRACK");
|
||||
else
|
||||
addValue("TRACK", String::number(i), true);
|
||||
|
||||
}
|
||||
|
||||
void APE::Tag::setPictures(const PictureMap &l) {
|
||||
|
||||
removeItem(FRONT_COVER);
|
||||
removeItem(BACK_COVER);
|
||||
|
||||
for (PictureMap::ConstIterator pictureMapIt = l.begin(); pictureMapIt != l.end(); ++pictureMapIt) {
|
||||
Picture::Type type = pictureMapIt->first;
|
||||
if (Picture::FrontCover != type && Picture::BackCover != type) {
|
||||
std::cout << "APE: Trying to add a picture with wrong type" << std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
const char *id;
|
||||
switch (type) {
|
||||
case Picture::FrontCover:
|
||||
id = FRONT_COVER;
|
||||
break;
|
||||
case Picture::BackCover:
|
||||
id = BACK_COVER;
|
||||
break;
|
||||
default:
|
||||
id = FRONT_COVER;
|
||||
break;
|
||||
}
|
||||
|
||||
PictureList list = pictureMapIt->second;
|
||||
for (PictureList::ConstIterator pictureListIt = list.begin(); pictureListIt != list.end(); ++pictureListIt) {
|
||||
Picture picture = *pictureListIt;
|
||||
if (d->itemListMap.contains(id)) {
|
||||
std::cout << "APE: Already added a picture of type "
|
||||
<< id
|
||||
<< " '"
|
||||
<< picture.description()
|
||||
<< "' "
|
||||
<< "and next are being ignored"
|
||||
<< std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
ByteVector data = picture.description().data(String::Latin1).append('\0').append(picture.data());
|
||||
|
||||
Item item;
|
||||
item.setKey(id);
|
||||
item.setType(Item::Binary);
|
||||
item.setBinaryData(data);
|
||||
setItem(item.key(), item);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace {
|
||||
@ -223,7 +316,7 @@ PropertyMap APE::Tag::properties() const {
|
||||
if (tagName == keyConversions[i][1])
|
||||
tagName = keyConversions[i][0];
|
||||
}
|
||||
properties[tagName].append(it->second.toStringList());
|
||||
properties[tagName].append(it->second.values());
|
||||
}
|
||||
}
|
||||
return properties;
|
||||
@ -397,18 +490,18 @@ void APE::Tag::parse(const ByteVector &data) {
|
||||
if (data.size() < 11)
|
||||
return;
|
||||
|
||||
unsigned int pos = 0;
|
||||
size_t pos = 0;
|
||||
|
||||
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) {
|
||||
const size_t nullPos = data.find('\0', pos + 8);
|
||||
if (nullPos == ByteVector::npos()) {
|
||||
debug("APE::Tag::parse() - Couldn't find a key/value separator. Stopped parsing.");
|
||||
return;
|
||||
}
|
||||
|
||||
const unsigned int keyLength = nullPos - pos - 8;
|
||||
const unsigned int valLegnth = data.toUInt(pos, false);
|
||||
const size_t keyLength = nullPos - pos - 8;
|
||||
const size_t valLegnth = data.toUInt32LE(pos);
|
||||
|
||||
if (keyLength >= MinKeyLength && keyLength <= MaxKeyLength && isKeyValid(data.mid(pos + 8, keyLength))) {
|
||||
APE::Item item;
|
||||
|
57
3rdparty/taglib/ape/apetag.h
vendored
57
3rdparty/taglib/ape/apetag.h
vendored
@ -34,6 +34,9 @@
|
||||
|
||||
#include "apeitem.h"
|
||||
|
||||
#define FRONT_COVER "COVER ART (FRONT)"
|
||||
#define BACK_COVER "COVER ART (BACK)"
|
||||
|
||||
namespace Strawberry_TagLib {
|
||||
namespace TagLib {
|
||||
|
||||
@ -50,7 +53,7 @@ class Footer;
|
||||
*
|
||||
* \see APE::Tag::itemListMap()
|
||||
*/
|
||||
typedef Map<const String, Item> ItemListMap;
|
||||
typedef Map<String, Item> ItemListMap;
|
||||
|
||||
|
||||
//! An APE tag implementation
|
||||
@ -66,12 +69,12 @@ class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||
* Create an APE tag and parse the data in \a file with APE footer at
|
||||
* \a tagOffset.
|
||||
*/
|
||||
explicit Tag(Strawberry_TagLib::TagLib::File *file, long footerLocation);
|
||||
explicit Tag(Strawberry_TagLib::TagLib::File *file, long long footerLocation);
|
||||
|
||||
/*!
|
||||
* Destroys this Tag instance.
|
||||
*/
|
||||
virtual ~Tag();
|
||||
~Tag() override;
|
||||
|
||||
/*!
|
||||
* Renders the in memory values to a ByteVector suitable for writing to the file.
|
||||
@ -85,21 +88,31 @@ class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||
|
||||
// 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;
|
||||
String title() const override;
|
||||
String artist() const override;
|
||||
String album() const override;
|
||||
String comment() const override;
|
||||
String genre() const override;
|
||||
unsigned int year() const override;
|
||||
unsigned int track() const override;
|
||||
|
||||
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);
|
||||
/**
|
||||
* @brief pictures
|
||||
* According to :
|
||||
* http://www.hydrogenaud.io/forums/index.php?showtopic=40603&st=50&p=504669&#entry504669
|
||||
* http://git.videolan.org/?p=vlc.git;a=blob;f=modules/meta_engine/taglib.cpp
|
||||
* @return
|
||||
*/
|
||||
PictureMap pictures() const override;
|
||||
|
||||
void setTitle(const String &s) override;
|
||||
void setArtist(const String &s) override;
|
||||
void setAlbum(const String &s) override;
|
||||
void setComment(const String &s) override;
|
||||
void setGenre(const String &s) override;
|
||||
void setYear(unsigned int i) override;
|
||||
void setTrack(unsigned int i) override;
|
||||
void setPictures(const PictureMap &l) override;
|
||||
|
||||
/*!
|
||||
* Implements the unified tag dictionary interface -- export function.
|
||||
@ -114,9 +127,9 @@ class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||
* 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 override;
|
||||
|
||||
void removeUnsupportedProperties(const StringList &properties);
|
||||
void removeUnsupportedProperties(const StringList &properties) override;
|
||||
|
||||
/*!
|
||||
* Implements the unified tag dictionary interface -- import function.
|
||||
@ -124,7 +137,7 @@ class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::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 &) override;
|
||||
|
||||
/*!
|
||||
* Check if the given String is a valid APE tag key.
|
||||
@ -176,7 +189,7 @@ class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||
/*!
|
||||
* Returns true if the tag does not contain any data.
|
||||
*/
|
||||
bool isEmpty() const;
|
||||
bool isEmpty() const override;
|
||||
|
||||
protected:
|
||||
/*!
|
||||
@ -190,7 +203,7 @@ class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||
void parse(const ByteVector &data);
|
||||
|
||||
private:
|
||||
explicit Tag(const Tag &);
|
||||
Tag(const Tag &);
|
||||
Tag &operator=(const Tag &);
|
||||
|
||||
class TagPrivate;
|
||||
|
170
3rdparty/taglib/asf/asfattribute.cpp
vendored
170
3rdparty/taglib/asf/asfattribute.cpp
vendored
@ -23,9 +23,10 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <taglib.h>
|
||||
#include <tdebug.h>
|
||||
#include <trefcounter.h>
|
||||
#include <memory>
|
||||
|
||||
#include "taglib.h"
|
||||
#include "tdebug.h"
|
||||
|
||||
#include "asfattribute.h"
|
||||
#include "asffile.h"
|
||||
@ -33,10 +34,11 @@
|
||||
|
||||
using namespace Strawberry_TagLib::TagLib;
|
||||
|
||||
class ASF::Attribute::AttributePrivate : public RefCounter {
|
||||
public:
|
||||
AttributePrivate() : pictureValue(ASF::Picture::fromInvalid()), numericValue(0), stream(0), language(0) {}
|
||||
AttributeTypes type;
|
||||
namespace {
|
||||
struct AttributeData {
|
||||
explicit AttributeData() : numericValue(0), stream(0), language(0) {}
|
||||
|
||||
ASF::Attribute::AttributeTypes type;
|
||||
String stringValue;
|
||||
ByteVector byteVectorValue;
|
||||
ASF::Picture pictureValue;
|
||||
@ -44,52 +46,60 @@ class ASF::Attribute::AttributePrivate : public RefCounter {
|
||||
int stream;
|
||||
int language;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
class ASF::Attribute::AttributePrivate {
|
||||
public:
|
||||
AttributePrivate() : data(new AttributeData()) {
|
||||
data->pictureValue = ASF::Picture::fromInvalid();
|
||||
}
|
||||
|
||||
std::shared_ptr<AttributeData> data;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// public members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ASF::Attribute::Attribute() : d(new AttributePrivate()) {
|
||||
d->type = UnicodeType;
|
||||
d->data->type = UnicodeType;
|
||||
}
|
||||
|
||||
ASF::Attribute::Attribute(const ASF::Attribute &other) : d(other.d) {
|
||||
d->ref();
|
||||
}
|
||||
ASF::Attribute::Attribute(const ASF::Attribute &other) : d(new AttributePrivate(*other.d)) {}
|
||||
|
||||
ASF::Attribute::Attribute(const String &value) : d(new AttributePrivate()) {
|
||||
d->type = UnicodeType;
|
||||
d->stringValue = value;
|
||||
d->data->type = UnicodeType;
|
||||
d->data->stringValue = value;
|
||||
}
|
||||
|
||||
ASF::Attribute::Attribute(const ByteVector &value) : d(new AttributePrivate()) {
|
||||
d->type = BytesType;
|
||||
d->byteVectorValue = value;
|
||||
d->data->type = BytesType;
|
||||
d->data->byteVectorValue = value;
|
||||
}
|
||||
|
||||
ASF::Attribute::Attribute(const ASF::Picture &value) : d(new AttributePrivate()) {
|
||||
d->type = BytesType;
|
||||
d->pictureValue = value;
|
||||
d->data->type = BytesType;
|
||||
d->data->pictureValue = value;
|
||||
}
|
||||
|
||||
ASF::Attribute::Attribute(unsigned int value) : d(new AttributePrivate()) {
|
||||
d->type = DWordType;
|
||||
d->numericValue = value;
|
||||
d->data->type = DWordType;
|
||||
d->data->numericValue = value;
|
||||
}
|
||||
|
||||
ASF::Attribute::Attribute(unsigned long long value) : d(new AttributePrivate()) {
|
||||
d->type = QWordType;
|
||||
d->numericValue = value;
|
||||
d->data->type = QWordType;
|
||||
d->data->numericValue = value;
|
||||
}
|
||||
|
||||
ASF::Attribute::Attribute(unsigned short value) : d(new AttributePrivate()) {
|
||||
d->type = WordType;
|
||||
d->numericValue = value;
|
||||
d->data->type = WordType;
|
||||
d->data->numericValue = value;
|
||||
}
|
||||
|
||||
ASF::Attribute::Attribute(bool value) : d(new AttributePrivate()) {
|
||||
d->type = BoolType;
|
||||
d->numericValue = value;
|
||||
d->data->type = BoolType;
|
||||
d->data->numericValue = value;
|
||||
}
|
||||
|
||||
ASF::Attribute &ASF::Attribute::operator=(const ASF::Attribute &other) {
|
||||
@ -104,54 +114,54 @@ void ASF::Attribute::swap(Attribute &other) {
|
||||
}
|
||||
|
||||
ASF::Attribute::~Attribute() {
|
||||
if (d->deref())
|
||||
delete d;
|
||||
delete d;
|
||||
}
|
||||
|
||||
ASF::Attribute::AttributeTypes ASF::Attribute::type() const {
|
||||
return d->type;
|
||||
return d->data->type;
|
||||
}
|
||||
|
||||
String ASF::Attribute::toString() const {
|
||||
return d->stringValue;
|
||||
return d->data->stringValue;
|
||||
}
|
||||
|
||||
ByteVector ASF::Attribute::toByteVector() const {
|
||||
if (d->pictureValue.isValid())
|
||||
return d->pictureValue.render();
|
||||
return d->byteVectorValue;
|
||||
if (d->data->pictureValue.isValid())
|
||||
return d->data->pictureValue.render();
|
||||
|
||||
return d->data->byteVectorValue;
|
||||
}
|
||||
|
||||
unsigned short ASF::Attribute::toBool() const {
|
||||
return d->numericValue ? 1 : 0;
|
||||
return d->data->numericValue ? 1 : 0;
|
||||
}
|
||||
|
||||
unsigned short ASF::Attribute::toUShort() const {
|
||||
return static_cast<unsigned short>(d->numericValue);
|
||||
return static_cast<unsigned short>(d->data->numericValue);
|
||||
}
|
||||
|
||||
unsigned int ASF::Attribute::toUInt() const {
|
||||
return static_cast<unsigned int>(d->numericValue);
|
||||
return static_cast<unsigned int>(d->data->numericValue);
|
||||
}
|
||||
|
||||
unsigned long long ASF::Attribute::toULongLong() const {
|
||||
return static_cast<unsigned long long>(d->numericValue);
|
||||
return static_cast<unsigned long long>(d->data->numericValue);
|
||||
}
|
||||
|
||||
ASF::Picture ASF::Attribute::toPicture() const {
|
||||
return d->pictureValue;
|
||||
return d->data->pictureValue;
|
||||
}
|
||||
|
||||
String ASF::Attribute::parse(ASF::File &f, int kind) {
|
||||
|
||||
unsigned int size, nameLength;
|
||||
String name;
|
||||
d->pictureValue = Picture::fromInvalid();
|
||||
d->data->pictureValue = Picture::fromInvalid();
|
||||
// extended content descriptor
|
||||
if (kind == 0) {
|
||||
nameLength = readWORD(&f);
|
||||
name = readString(&f, nameLength);
|
||||
d->type = ASF::Attribute::AttributeTypes(readWORD(&f));
|
||||
d->data->type = ASF::Attribute::AttributeTypes(readWORD(&f));
|
||||
size = readWORD(&f);
|
||||
}
|
||||
// metadata & metadata library
|
||||
@ -159,11 +169,11 @@ String ASF::Attribute::parse(ASF::File &f, int kind) {
|
||||
int temp = readWORD(&f);
|
||||
// metadata library
|
||||
if (kind == 2) {
|
||||
d->language = temp;
|
||||
d->data->language = temp;
|
||||
}
|
||||
d->stream = readWORD(&f);
|
||||
d->data->stream = readWORD(&f);
|
||||
nameLength = readWORD(&f);
|
||||
d->type = ASF::Attribute::AttributeTypes(readWORD(&f));
|
||||
d->data->type = ASF::Attribute::AttributeTypes(readWORD(&f));
|
||||
size = readDWORD(&f);
|
||||
name = readString(&f, nameLength);
|
||||
}
|
||||
@ -172,42 +182,42 @@ String ASF::Attribute::parse(ASF::File &f, int kind) {
|
||||
debug("ASF::Attribute::parse() -- Value larger than 64kB");
|
||||
}
|
||||
|
||||
switch (d->type) {
|
||||
switch (d->data->type) {
|
||||
case WordType:
|
||||
d->numericValue = readWORD(&f);
|
||||
d->data->numericValue = readWORD(&f);
|
||||
break;
|
||||
|
||||
case BoolType:
|
||||
if (kind == 0) {
|
||||
d->numericValue = (readDWORD(&f) != 0);
|
||||
d->data->numericValue = (readDWORD(&f) != 0);
|
||||
}
|
||||
else {
|
||||
d->numericValue = (readWORD(&f) != 0);
|
||||
d->data->numericValue = (readWORD(&f) != 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case DWordType:
|
||||
d->numericValue = readDWORD(&f);
|
||||
d->data->numericValue = readDWORD(&f);
|
||||
break;
|
||||
|
||||
case QWordType:
|
||||
d->numericValue = readQWORD(&f);
|
||||
d->data->numericValue = readQWORD(&f);
|
||||
break;
|
||||
|
||||
case UnicodeType:
|
||||
d->stringValue = readString(&f, size);
|
||||
d->data->stringValue = readString(&f, size);
|
||||
break;
|
||||
|
||||
case BytesType:
|
||||
case GuidType:
|
||||
d->byteVectorValue = f.readBlock(size);
|
||||
d->data->byteVectorValue = f.readBlock(size);
|
||||
break;
|
||||
}
|
||||
|
||||
if (d->type == BytesType && name == "WM/Picture") {
|
||||
d->pictureValue.parse(d->byteVectorValue);
|
||||
if (d->pictureValue.isValid()) {
|
||||
d->byteVectorValue.clear();
|
||||
if (d->data->type == BytesType && name == "WM/Picture") {
|
||||
d->data->pictureValue.parse(d->data->byteVectorValue);
|
||||
if (d->data->pictureValue.isValid()) {
|
||||
d->data->byteVectorValue.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@ -217,7 +227,7 @@ String ASF::Attribute::parse(ASF::File &f, int kind) {
|
||||
|
||||
int ASF::Attribute::dataSize() const {
|
||||
|
||||
switch (d->type) {
|
||||
switch (d->data->type) {
|
||||
case WordType:
|
||||
return 2;
|
||||
case BoolType:
|
||||
@ -227,13 +237,13 @@ int ASF::Attribute::dataSize() const {
|
||||
case QWordType:
|
||||
return 5;
|
||||
case UnicodeType:
|
||||
return d->stringValue.size() * 2 + 2;
|
||||
return static_cast<int>(d->data->stringValue.size() * 2 + 2);
|
||||
case BytesType:
|
||||
if (d->pictureValue.isValid())
|
||||
return d->pictureValue.dataSize();
|
||||
if (d->data->pictureValue.isValid())
|
||||
return d->data->pictureValue.dataSize();
|
||||
break;
|
||||
case GuidType:
|
||||
return d->byteVectorValue.size();
|
||||
return static_cast<int>(d->data->byteVectorValue.size());
|
||||
}
|
||||
return 0;
|
||||
|
||||
@ -243,56 +253,56 @@ ByteVector ASF::Attribute::render(const String &name, int kind) const {
|
||||
|
||||
ByteVector data;
|
||||
|
||||
switch (d->type) {
|
||||
switch (d->data->type) {
|
||||
case WordType:
|
||||
data.append(ByteVector::fromShort(toUShort(), false));
|
||||
data.append(ByteVector::fromUInt16LE(toUShort()));
|
||||
break;
|
||||
|
||||
case BoolType:
|
||||
if (kind == 0) {
|
||||
data.append(ByteVector::fromUInt(toBool(), false));
|
||||
data.append(ByteVector::fromUInt32LE(toBool()));
|
||||
}
|
||||
else {
|
||||
data.append(ByteVector::fromShort(toBool(), false));
|
||||
data.append(ByteVector::fromUInt16LE(toBool()));
|
||||
}
|
||||
break;
|
||||
|
||||
case DWordType:
|
||||
data.append(ByteVector::fromUInt(toUInt(), false));
|
||||
data.append(ByteVector::fromUInt32LE(toUInt()));
|
||||
break;
|
||||
|
||||
case QWordType:
|
||||
data.append(ByteVector::fromLongLong(toULongLong(), false));
|
||||
data.append(ByteVector::fromUInt64LE(toULongLong()));
|
||||
break;
|
||||
|
||||
case UnicodeType:
|
||||
data.append(renderString(d->stringValue));
|
||||
data.append(renderString(d->data->stringValue));
|
||||
break;
|
||||
|
||||
case BytesType:
|
||||
if (d->pictureValue.isValid()) {
|
||||
data.append(d->pictureValue.render());
|
||||
if (d->data->pictureValue.isValid()) {
|
||||
data.append(d->data->pictureValue.render());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case GuidType:
|
||||
data.append(d->byteVectorValue);
|
||||
data.append(d->data->byteVectorValue);
|
||||
break;
|
||||
}
|
||||
|
||||
if (kind == 0) {
|
||||
data = renderString(name, true) +
|
||||
ByteVector::fromShort(static_cast<int>(d->type), false) +
|
||||
ByteVector::fromShort(data.size(), false) +
|
||||
ByteVector::fromUInt16LE((int)d->data->type) +
|
||||
ByteVector::fromUInt16LE(data.size()) +
|
||||
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(static_cast<int>(d->type), false) +
|
||||
ByteVector::fromUInt(data.size(), false) +
|
||||
data = ByteVector::fromUInt16LE(kind == 2 ? d->data->language : 0) +
|
||||
ByteVector::fromUInt16LE(d->data->stream) +
|
||||
ByteVector::fromUInt16LE(nameData.size()) +
|
||||
ByteVector::fromUInt16LE(static_cast<int>(d->data->type)) +
|
||||
ByteVector::fromUInt32LE(data.size()) +
|
||||
nameData +
|
||||
data;
|
||||
}
|
||||
@ -302,17 +312,17 @@ ByteVector ASF::Attribute::render(const String &name, int kind) const {
|
||||
}
|
||||
|
||||
int ASF::Attribute::language() const {
|
||||
return d->language;
|
||||
return d->data->language;
|
||||
}
|
||||
|
||||
void ASF::Attribute::setLanguage(int value) {
|
||||
d->language = value;
|
||||
d->data->language = value;
|
||||
}
|
||||
|
||||
int ASF::Attribute::stream() const {
|
||||
return d->stream;
|
||||
return d->data->stream;
|
||||
}
|
||||
|
||||
void ASF::Attribute::setStream(int value) {
|
||||
d->stream = value;
|
||||
d->data->stream = value;
|
||||
}
|
||||
|
20
3rdparty/taglib/asf/asfattribute.h
vendored
20
3rdparty/taglib/asf/asfattribute.h
vendored
@ -56,7 +56,7 @@ class TAGLIB_EXPORT Attribute {
|
||||
/*!
|
||||
* Constructs an empty attribute.
|
||||
*/
|
||||
explicit Attribute();
|
||||
Attribute();
|
||||
|
||||
/*!
|
||||
* Constructs an attribute with \a key and a UnicodeType \a value.
|
||||
@ -66,7 +66,7 @@ class TAGLIB_EXPORT Attribute {
|
||||
/*!
|
||||
* Constructs an attribute with \a key and a BytesType \a value.
|
||||
*/
|
||||
explicit Attribute(const ByteVector &value);
|
||||
Attribute(const ByteVector &value);
|
||||
|
||||
/*!
|
||||
* Constructs an attribute with \a key and a Picture \a value.
|
||||
@ -79,27 +79,27 @@ class TAGLIB_EXPORT Attribute {
|
||||
* 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.
|
||||
*/
|
||||
explicit Attribute(const Picture &value);
|
||||
Attribute(const Picture &value);
|
||||
|
||||
/*!
|
||||
* Constructs an attribute with \a key and a DWordType \a value.
|
||||
*/
|
||||
explicit Attribute(unsigned int value);
|
||||
Attribute(unsigned int value);
|
||||
|
||||
/*!
|
||||
* Constructs an attribute with \a key and a QWordType \a value.
|
||||
*/
|
||||
explicit Attribute(unsigned long long value);
|
||||
Attribute(unsigned long long value);
|
||||
|
||||
/*!
|
||||
* Constructs an attribute with \a key and a WordType \a value.
|
||||
*/
|
||||
explicit Attribute(unsigned short value);
|
||||
Attribute(unsigned short value);
|
||||
|
||||
/*!
|
||||
* Constructs an attribute with \a key and a BoolType \a value.
|
||||
*/
|
||||
explicit Attribute(bool value);
|
||||
Attribute(bool value);
|
||||
|
||||
/*!
|
||||
* Construct an attribute as a copy of \a other.
|
||||
@ -181,17 +181,13 @@ class TAGLIB_EXPORT Attribute {
|
||||
*/
|
||||
void setStream(int value);
|
||||
|
||||
#ifndef DO_NOT_DOCUMENT
|
||||
/* 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;
|
||||
|
||||
private:
|
||||
friend class File;
|
||||
|
||||
String parse(ASF::File &file, int kind = 0);
|
||||
ByteVector render(const String &name, int kind = 0) const;
|
||||
|
||||
class AttributePrivate;
|
||||
|
161
3rdparty/taglib/asf/asffile.cpp
vendored
161
3rdparty/taglib/asf/asffile.cpp
vendored
@ -23,11 +23,13 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tdebug.h>
|
||||
#include <tbytevectorlist.h>
|
||||
#include <tpropertymap.h>
|
||||
#include <tstring.h>
|
||||
#include <tagutils.h>
|
||||
#include <memory>
|
||||
|
||||
#include "tdebug.h"
|
||||
#include "tbytevectorlist.h"
|
||||
#include "tpropertymap.h"
|
||||
#include "tstring.h"
|
||||
#include "tagutils.h"
|
||||
|
||||
#include "asffile.h"
|
||||
#include "asftag.h"
|
||||
@ -49,34 +51,23 @@ class ASF::File::FilePrivate {
|
||||
class MetadataObject;
|
||||
class MetadataLibraryObject;
|
||||
|
||||
FilePrivate() : headerSize(0),
|
||||
tag(nullptr),
|
||||
properties(nullptr),
|
||||
contentDescriptionObject(nullptr),
|
||||
extendedContentDescriptionObject(nullptr),
|
||||
headerExtensionObject(nullptr),
|
||||
metadataObject(nullptr),
|
||||
metadataLibraryObject(nullptr) {
|
||||
objects.setAutoDelete(true);
|
||||
}
|
||||
typedef List<std::shared_ptr<BaseObject>> ObjectList;
|
||||
typedef ObjectList::ConstIterator ObjectConstIterator;
|
||||
|
||||
~FilePrivate() {
|
||||
delete tag;
|
||||
delete properties;
|
||||
}
|
||||
FilePrivate() : headerSize(0) {}
|
||||
|
||||
unsigned long long headerSize;
|
||||
|
||||
ASF::Tag *tag;
|
||||
ASF::AudioProperties *properties;
|
||||
std::unique_ptr<ASF::Tag> tag;
|
||||
std::unique_ptr<ASF::AudioProperties> properties;
|
||||
|
||||
List<BaseObject *> objects;
|
||||
ObjectList objects;
|
||||
|
||||
ContentDescriptionObject *contentDescriptionObject;
|
||||
ExtendedContentDescriptionObject *extendedContentDescriptionObject;
|
||||
HeaderExtensionObject *headerExtensionObject;
|
||||
MetadataObject *metadataObject;
|
||||
MetadataLibraryObject *metadataLibraryObject;
|
||||
std::shared_ptr<ContentDescriptionObject> contentDescriptionObject;
|
||||
std::shared_ptr<ExtendedContentDescriptionObject> extendedContentDescriptionObject;
|
||||
std::shared_ptr<HeaderExtensionObject> headerExtensionObject;
|
||||
std::shared_ptr<MetadataObject> metadataObject;
|
||||
std::shared_ptr<MetadataLibraryObject> metadataLibraryObject;
|
||||
};
|
||||
|
||||
namespace {
|
||||
@ -156,7 +147,7 @@ class ASF::File::FilePrivate::MetadataLibraryObject : public ASF::File::FilePriv
|
||||
|
||||
class ASF::File::FilePrivate::HeaderExtensionObject : public ASF::File::FilePrivate::BaseObject {
|
||||
public:
|
||||
List<ASF::File::FilePrivate::BaseObject *> objects;
|
||||
ObjectList objects;
|
||||
HeaderExtensionObject();
|
||||
ByteVector guid() const override;
|
||||
void parse(ASF::File *file, unsigned int size) override;
|
||||
@ -179,7 +170,7 @@ class ASF::File::FilePrivate::CodecListObject : public ASF::File::FilePrivate::B
|
||||
void ASF::File::FilePrivate::BaseObject::parse(ASF::File *file, unsigned int size) {
|
||||
|
||||
data.clear();
|
||||
if (size > 24 && size <= static_cast<unsigned int>(file->length()))
|
||||
if (size > 24 && static_cast<long long>(size) <= file->length())
|
||||
data = file->readBlock(size - 24);
|
||||
else
|
||||
data = ByteVector();
|
||||
@ -187,7 +178,7 @@ void ASF::File::FilePrivate::BaseObject::parse(ASF::File *file, unsigned int siz
|
||||
}
|
||||
|
||||
ByteVector ASF::File::FilePrivate::BaseObject::render(ASF::File * /*file*/) {
|
||||
return guid() + ByteVector::fromLongLong(data.size() + 24, false) + data;
|
||||
return guid() + ByteVector::fromUInt64LE(data.size() + 24) + data;
|
||||
}
|
||||
|
||||
ASF::File::FilePrivate::UnknownObject::UnknownObject(const ByteVector &guid) : myGuid(guid) {}
|
||||
@ -208,8 +199,8 @@ void ASF::File::FilePrivate::FilePropertiesObject::parse(ASF::File *file, unsign
|
||||
return;
|
||||
}
|
||||
|
||||
const long long duration = data.toLongLong(40, false);
|
||||
const long long preroll = data.toLongLong(56, false);
|
||||
const long long duration = data.toInt64LE(40);
|
||||
const long long preroll = data.toInt64LE(56);
|
||||
file->d->properties->setLengthInMilliseconds(static_cast<int>(duration / 10000.0 - preroll + 0.5));
|
||||
|
||||
}
|
||||
@ -226,11 +217,11 @@ void ASF::File::FilePrivate::StreamPropertiesObject::parse(ASF::File *file, unsi
|
||||
return;
|
||||
}
|
||||
|
||||
file->d->properties->setCodec(data.toUShort(54, false));
|
||||
file->d->properties->setChannels(data.toUShort(56, false));
|
||||
file->d->properties->setSampleRate(data.toUInt(58, false));
|
||||
file->d->properties->setBitrate(static_cast<int>(data.toUInt(62, false) * 8.0 / 1000.0 + 0.5));
|
||||
file->d->properties->setBitsPerSample(data.toUShort(68, false));
|
||||
file->d->properties->setCodec(data.toUInt16LE(54));
|
||||
file->d->properties->setChannels(data.toUInt16LE(56));
|
||||
file->d->properties->setSampleRate(data.toUInt32LE(58));
|
||||
file->d->properties->setBitrate(static_cast<int>(data.toUInt32LE(62) * 8.0 / 1000.0 + 0.5));
|
||||
file->d->properties->setBitsPerSample(data.toUInt16LE(68));
|
||||
|
||||
}
|
||||
|
||||
@ -261,11 +252,11 @@ ByteVector ASF::File::FilePrivate::ContentDescriptionObject::render(ASF::File *f
|
||||
const ByteVector v4 = renderString(file->d->tag->comment());
|
||||
const ByteVector v5 = renderString(file->d->tag->rating());
|
||||
data.clear();
|
||||
data.append(ByteVector::fromShort(v1.size(), false));
|
||||
data.append(ByteVector::fromShort(v2.size(), false));
|
||||
data.append(ByteVector::fromShort(v3.size(), false));
|
||||
data.append(ByteVector::fromShort(v4.size(), false));
|
||||
data.append(ByteVector::fromShort(v5.size(), false));
|
||||
data.append(ByteVector::fromUInt16LE(v1.size()));
|
||||
data.append(ByteVector::fromUInt16LE(v2.size()));
|
||||
data.append(ByteVector::fromUInt16LE(v3.size()));
|
||||
data.append(ByteVector::fromUInt16LE(v4.size()));
|
||||
data.append(ByteVector::fromUInt16LE(v5.size()));
|
||||
data.append(v1);
|
||||
data.append(v2);
|
||||
data.append(v3);
|
||||
@ -293,7 +284,7 @@ void ASF::File::FilePrivate::ExtendedContentDescriptionObject::parse(ASF::File *
|
||||
ByteVector ASF::File::FilePrivate::ExtendedContentDescriptionObject::render(ASF::File *file) {
|
||||
|
||||
data.clear();
|
||||
data.append(ByteVector::fromShort(attributeData.size(), false));
|
||||
data.append(ByteVector::fromUInt16LE(attributeData.size()));
|
||||
data.append(attributeData.toByteVector(""));
|
||||
return BaseObject::render(file);
|
||||
|
||||
@ -317,7 +308,7 @@ void ASF::File::FilePrivate::MetadataObject::parse(ASF::File *file, unsigned int
|
||||
ByteVector ASF::File::FilePrivate::MetadataObject::render(ASF::File *file) {
|
||||
|
||||
data.clear();
|
||||
data.append(ByteVector::fromShort(attributeData.size(), false));
|
||||
data.append(ByteVector::fromUInt16LE(attributeData.size()));
|
||||
data.append(attributeData.toByteVector(""));
|
||||
return BaseObject::render(file);
|
||||
|
||||
@ -341,7 +332,7 @@ void ASF::File::FilePrivate::MetadataLibraryObject::parse(ASF::File *file, unsig
|
||||
ByteVector ASF::File::FilePrivate::MetadataLibraryObject::render(ASF::File *file) {
|
||||
|
||||
data.clear();
|
||||
data.append(ByteVector::fromShort(attributeData.size(), false));
|
||||
data.append(ByteVector::fromUInt16LE(attributeData.size()));
|
||||
data.append(attributeData.toByteVector(""));
|
||||
return BaseObject::render(file);
|
||||
|
||||
@ -372,17 +363,17 @@ void ASF::File::FilePrivate::HeaderExtensionObject::parse(ASF::File *file, unsig
|
||||
file->setValid(false);
|
||||
break;
|
||||
}
|
||||
BaseObject *obj;
|
||||
std::shared_ptr<BaseObject> obj;
|
||||
if (guid == metadataGuid) {
|
||||
file->d->metadataObject = new MetadataObject();
|
||||
file->d->metadataObject.reset(new MetadataObject());
|
||||
obj = file->d->metadataObject;
|
||||
}
|
||||
else if (guid == metadataLibraryGuid) {
|
||||
file->d->metadataLibraryObject = new MetadataLibraryObject();
|
||||
file->d->metadataLibraryObject.reset(new MetadataLibraryObject());
|
||||
obj = file->d->metadataLibraryObject;
|
||||
}
|
||||
else {
|
||||
obj = new UnknownObject(guid);
|
||||
obj.reset(new UnknownObject(guid));
|
||||
}
|
||||
obj->parse(file, static_cast<unsigned int>(size));
|
||||
objects.append(obj);
|
||||
@ -394,10 +385,10 @@ void ASF::File::FilePrivate::HeaderExtensionObject::parse(ASF::File *file, unsig
|
||||
ByteVector ASF::File::FilePrivate::HeaderExtensionObject::render(ASF::File *file) {
|
||||
|
||||
data.clear();
|
||||
for (List<BaseObject *>::ConstIterator it = objects.begin(); it != objects.end(); ++it) {
|
||||
for (ObjectConstIterator 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;
|
||||
data = ByteVector("\x11\xD2\xD3\xAB\xBA\xA9\xcf\x11\x8E\xE6\x00\xC0\x0C\x20\x53\x65\x06\x00", 18) + ByteVector::fromUInt32LE(data.size()) + data;
|
||||
return BaseObject::render(file);
|
||||
|
||||
}
|
||||
@ -416,7 +407,7 @@ void ASF::File::FilePrivate::CodecListObject::parse(ASF::File *file, unsigned in
|
||||
|
||||
unsigned int pos = 16;
|
||||
|
||||
const int count = data.toUInt(pos, false);
|
||||
const int count = data.toUInt32LE(pos);
|
||||
pos += 4;
|
||||
|
||||
for (int i = 0; i < count; ++i) {
|
||||
@ -424,22 +415,22 @@ void ASF::File::FilePrivate::CodecListObject::parse(ASF::File *file, unsigned in
|
||||
if (pos >= data.size())
|
||||
break;
|
||||
|
||||
const CodecType type = static_cast<CodecType>(data.toUShort(pos, false));
|
||||
const CodecType type = static_cast<CodecType>(data.toUInt16LE(pos));
|
||||
pos += 2;
|
||||
|
||||
int nameLength = data.toUShort(pos, false);
|
||||
int nameLength = data.toUInt16LE(pos);
|
||||
pos += 2;
|
||||
|
||||
const unsigned int namePos = pos;
|
||||
pos += nameLength * 2;
|
||||
|
||||
const int descLength = data.toUShort(pos, false);
|
||||
const int descLength = data.toUInt16LE(pos);
|
||||
pos += 2;
|
||||
|
||||
const unsigned int descPos = pos;
|
||||
pos += descLength * 2;
|
||||
|
||||
const int infoLength = data.toUShort(pos, false);
|
||||
const int infoLength = data.toUInt16LE(pos);
|
||||
pos += 2 + infoLength * 2;
|
||||
|
||||
if (type == CodecListObject::Audio) {
|
||||
@ -489,23 +480,11 @@ ASF::File::~File() {
|
||||
}
|
||||
|
||||
ASF::Tag *ASF::File::tag() const {
|
||||
return d->tag;
|
||||
}
|
||||
|
||||
PropertyMap ASF::File::properties() const {
|
||||
return d->tag->properties();
|
||||
}
|
||||
|
||||
void ASF::File::removeUnsupportedProperties(const StringList &properties) {
|
||||
d->tag->removeUnsupportedProperties(properties);
|
||||
}
|
||||
|
||||
PropertyMap ASF::File::setProperties(const PropertyMap &properties) {
|
||||
return d->tag->setProperties(properties);
|
||||
return d->tag.get();
|
||||
}
|
||||
|
||||
ASF::AudioProperties *ASF::File::audioProperties() const {
|
||||
return d->properties;
|
||||
return d->properties.get();
|
||||
}
|
||||
|
||||
bool ASF::File::save() {
|
||||
@ -521,23 +500,23 @@ bool ASF::File::save() {
|
||||
}
|
||||
|
||||
if (!d->contentDescriptionObject) {
|
||||
d->contentDescriptionObject = new FilePrivate::ContentDescriptionObject();
|
||||
d->contentDescriptionObject.reset(new FilePrivate::ContentDescriptionObject());
|
||||
d->objects.append(d->contentDescriptionObject);
|
||||
}
|
||||
if (!d->extendedContentDescriptionObject) {
|
||||
d->extendedContentDescriptionObject = new FilePrivate::ExtendedContentDescriptionObject();
|
||||
d->extendedContentDescriptionObject.reset(new FilePrivate::ExtendedContentDescriptionObject());
|
||||
d->objects.append(d->extendedContentDescriptionObject);
|
||||
}
|
||||
if (!d->headerExtensionObject) {
|
||||
d->headerExtensionObject = new FilePrivate::HeaderExtensionObject();
|
||||
d->headerExtensionObject.reset(new FilePrivate::HeaderExtensionObject());
|
||||
d->objects.append(d->headerExtensionObject);
|
||||
}
|
||||
if (!d->metadataObject) {
|
||||
d->metadataObject = new FilePrivate::MetadataObject();
|
||||
d->metadataObject.reset(new FilePrivate::MetadataObject());
|
||||
d->headerExtensionObject->objects.append(d->metadataObject);
|
||||
}
|
||||
if (!d->metadataLibraryObject) {
|
||||
d->metadataLibraryObject = new FilePrivate::MetadataLibraryObject();
|
||||
d->metadataLibraryObject.reset(new FilePrivate::MetadataLibraryObject());
|
||||
d->headerExtensionObject->objects.append(d->metadataLibraryObject);
|
||||
}
|
||||
|
||||
@ -576,16 +555,16 @@ bool ASF::File::save() {
|
||||
}
|
||||
|
||||
ByteVector data;
|
||||
for (List<FilePrivate::BaseObject *>::ConstIterator it = d->objects.begin(); it != d->objects.end(); ++it) {
|
||||
for (FilePrivate::ObjectConstIterator it = d->objects.begin(); it != d->objects.end(); ++it) {
|
||||
data.append((*it)->render(this));
|
||||
}
|
||||
|
||||
seek(16);
|
||||
writeBlock(ByteVector::fromLongLong(data.size() + 30, false));
|
||||
writeBlock(ByteVector::fromUInt(d->objects.size(), false));
|
||||
writeBlock(ByteVector::fromUInt64LE(data.size() + 30));
|
||||
writeBlock(ByteVector::fromUInt32LE(d->objects.size()));
|
||||
writeBlock(ByteVector("\x01\x02", 2));
|
||||
|
||||
insert(data, 30, static_cast<unsigned long>(d->headerSize - 30));
|
||||
insert(data, 30, static_cast<size_t>(d->headerSize - 30));
|
||||
|
||||
d->headerSize = data.size() + 30;
|
||||
|
||||
@ -608,8 +587,8 @@ void ASF::File::read() {
|
||||
return;
|
||||
}
|
||||
|
||||
d->tag = new ASF::Tag();
|
||||
d->properties = new ASF::AudioProperties();
|
||||
d->tag.reset(new ASF::Tag());
|
||||
d->properties.reset(new ASF::AudioProperties());
|
||||
|
||||
bool ok;
|
||||
d->headerSize = readQWORD(this, &ok);
|
||||
@ -624,8 +603,8 @@ void ASF::File::read() {
|
||||
}
|
||||
seek(2, Current);
|
||||
|
||||
FilePrivate::FilePropertiesObject *filePropertiesObject = nullptr;
|
||||
FilePrivate::StreamPropertiesObject *streamPropertiesObject = nullptr;
|
||||
std::shared_ptr<FilePrivate::FilePropertiesObject> filePropertiesObject;
|
||||
std::shared_ptr<FilePrivate::StreamPropertiesObject> streamPropertiesObject;
|
||||
for (int i = 0; i < numObjects; i++) {
|
||||
const ByteVector guid = readBlock(16);
|
||||
if (guid.size() != 16) {
|
||||
@ -637,29 +616,29 @@ void ASF::File::read() {
|
||||
setValid(false);
|
||||
break;
|
||||
}
|
||||
FilePrivate::BaseObject *obj;
|
||||
std::shared_ptr<FilePrivate::BaseObject> obj;
|
||||
if (guid == filePropertiesGuid) {
|
||||
filePropertiesObject = new FilePrivate::FilePropertiesObject();
|
||||
filePropertiesObject.reset(new FilePrivate::FilePropertiesObject());
|
||||
obj = filePropertiesObject;
|
||||
}
|
||||
else if (guid == streamPropertiesGuid) {
|
||||
streamPropertiesObject = new FilePrivate::StreamPropertiesObject();
|
||||
streamPropertiesObject.reset(new FilePrivate::StreamPropertiesObject());
|
||||
obj = streamPropertiesObject;
|
||||
}
|
||||
else if (guid == contentDescriptionGuid) {
|
||||
d->contentDescriptionObject = new FilePrivate::ContentDescriptionObject();
|
||||
d->contentDescriptionObject.reset(new FilePrivate::ContentDescriptionObject());
|
||||
obj = d->contentDescriptionObject;
|
||||
}
|
||||
else if (guid == extendedContentDescriptionGuid) {
|
||||
d->extendedContentDescriptionObject = new FilePrivate::ExtendedContentDescriptionObject();
|
||||
d->extendedContentDescriptionObject.reset(new FilePrivate::ExtendedContentDescriptionObject());
|
||||
obj = d->extendedContentDescriptionObject;
|
||||
}
|
||||
else if (guid == headerExtensionGuid) {
|
||||
d->headerExtensionObject = new FilePrivate::HeaderExtensionObject();
|
||||
d->headerExtensionObject.reset(new FilePrivate::HeaderExtensionObject());
|
||||
obj = d->headerExtensionObject;
|
||||
}
|
||||
else if (guid == codecListGuid) {
|
||||
obj = new FilePrivate::CodecListObject();
|
||||
obj.reset(new FilePrivate::CodecListObject());
|
||||
}
|
||||
else {
|
||||
if (guid == contentEncryptionGuid ||
|
||||
@ -667,7 +646,7 @@ void ASF::File::read() {
|
||||
guid == advancedContentEncryptionGuid) {
|
||||
d->properties->setEncrypted(true);
|
||||
}
|
||||
obj = new FilePrivate::UnknownObject(guid);
|
||||
obj.reset(new FilePrivate::UnknownObject(guid));
|
||||
}
|
||||
obj->parse(this, size);
|
||||
d->objects.append(obj);
|
||||
|
23
3rdparty/taglib/asf/asffile.h
vendored
23
3rdparty/taglib/asf/asffile.h
vendored
@ -70,7 +70,7 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
|
||||
/*!
|
||||
* Destroys this instance of the File.
|
||||
*/
|
||||
virtual ~File();
|
||||
~File() override;
|
||||
|
||||
/*!
|
||||
* Returns a pointer to the ASF tag of the file.
|
||||
@ -82,34 +82,19 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
|
||||
* deleted by the user. It will be deleted when the file (object) is
|
||||
* destroyed.
|
||||
*/
|
||||
virtual Tag *tag() const;
|
||||
|
||||
/*!
|
||||
* Implements the unified property interface -- export function.
|
||||
*/
|
||||
PropertyMap properties() const;
|
||||
|
||||
/*!
|
||||
* Removes unsupported properties. Forwards to the actual Tag's removeUnsupportedProperties() function.
|
||||
*/
|
||||
void removeUnsupportedProperties(const StringList &properties);
|
||||
|
||||
/*!
|
||||
* Implements the unified property interface -- import function.
|
||||
*/
|
||||
PropertyMap setProperties(const PropertyMap &);
|
||||
Tag *tag() const override;
|
||||
|
||||
/*!
|
||||
* Returns the ASF audio properties for this file.
|
||||
*/
|
||||
virtual AudioProperties *audioProperties() const;
|
||||
AudioProperties *audioProperties() const override;
|
||||
|
||||
/*!
|
||||
* Save the file.
|
||||
*
|
||||
* This returns true if the save was successful.
|
||||
*/
|
||||
virtual bool save();
|
||||
bool save() override;
|
||||
|
||||
/*!
|
||||
* Returns whether or not the given \a stream can be opened as an ASF file.
|
||||
|
81
3rdparty/taglib/asf/asfpicture.cpp
vendored
81
3rdparty/taglib/asf/asfpicture.cpp
vendored
@ -23,9 +23,10 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <taglib.h>
|
||||
#include <tdebug.h>
|
||||
#include <trefcounter.h>
|
||||
#include <memory>
|
||||
|
||||
#include "taglib.h"
|
||||
#include "tdebug.h"
|
||||
|
||||
#include "asfattribute.h"
|
||||
#include "asffile.h"
|
||||
@ -34,71 +35,75 @@
|
||||
|
||||
using namespace Strawberry_TagLib::TagLib;
|
||||
|
||||
class ASF::Picture::PicturePrivate : public RefCounter {
|
||||
public:
|
||||
namespace {
|
||||
struct PictureData {
|
||||
bool valid;
|
||||
Type type;
|
||||
ASF::Picture::Type type;
|
||||
String mimeType;
|
||||
String description;
|
||||
ByteVector picture;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
class ASF::Picture::PicturePrivate {
|
||||
public:
|
||||
explicit PicturePrivate() : data(new PictureData()) {}
|
||||
|
||||
std::shared_ptr<PictureData> data;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Picture class members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ASF::Picture::Picture() : d(new PicturePrivate()) {
|
||||
d->valid = true;
|
||||
d->data->valid = true;
|
||||
}
|
||||
|
||||
ASF::Picture::Picture(const Picture& other) : d(other.d) {
|
||||
d->ref();
|
||||
}
|
||||
ASF::Picture::Picture(const Picture& other) : d(new PicturePrivate(*other.d)) {}
|
||||
|
||||
ASF::Picture::~Picture() {
|
||||
if (d->deref())
|
||||
delete d;
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool ASF::Picture::isValid() const {
|
||||
return d->valid;
|
||||
return d->data->valid;
|
||||
}
|
||||
|
||||
String ASF::Picture::mimeType() const {
|
||||
return d->mimeType;
|
||||
return d->data->mimeType;
|
||||
}
|
||||
|
||||
void ASF::Picture::setMimeType(const String& value) {
|
||||
d->mimeType = value;
|
||||
d->data->mimeType = value;
|
||||
}
|
||||
|
||||
ASF::Picture::Type ASF::Picture::type() const {
|
||||
return d->type;
|
||||
return d->data->type;
|
||||
}
|
||||
|
||||
void ASF::Picture::setType(const ASF::Picture::Type &t) {
|
||||
d->type = t;
|
||||
d->data->type = t;
|
||||
}
|
||||
|
||||
String ASF::Picture::description() const {
|
||||
return d->description;
|
||||
return d->data->description;
|
||||
}
|
||||
|
||||
void ASF::Picture::setDescription(const String& desc) {
|
||||
d->description = desc;
|
||||
d->data->description = desc;
|
||||
}
|
||||
|
||||
ByteVector ASF::Picture::picture() const {
|
||||
return d->picture;
|
||||
return d->data->picture;
|
||||
}
|
||||
|
||||
void ASF::Picture::setPicture(const ByteVector &p) {
|
||||
d->picture = p;
|
||||
d->data->picture = p;
|
||||
}
|
||||
|
||||
int ASF::Picture::dataSize() const {
|
||||
return 9 + (d->mimeType.length() + d->description.length()) * 2 +
|
||||
d->picture.size();
|
||||
return 9 + (d->data->mimeType.length() + d->data->description.length()) * 2 + d->data->picture.size();
|
||||
}
|
||||
|
||||
ASF::Picture& ASF::Picture::operator=(const ASF::Picture& other) {
|
||||
@ -117,51 +122,47 @@ ByteVector ASF::Picture::render() const {
|
||||
if (!isValid())
|
||||
return ByteVector();
|
||||
|
||||
return ByteVector(static_cast<char>(d->type)) +
|
||||
ByteVector::fromUInt(d->picture.size(), false) +
|
||||
renderString(d->mimeType) +
|
||||
renderString(d->description) +
|
||||
d->picture;
|
||||
return ByteVector(static_cast<char>(d->data->type)) + ByteVector::fromUInt32LE(d->data->picture.size()) + renderString(d->data->mimeType) + renderString(d->data->description) + d->data->picture;
|
||||
|
||||
}
|
||||
|
||||
void ASF::Picture::parse(const ByteVector &bytes) {
|
||||
|
||||
d->valid = false;
|
||||
d->data->valid = false;
|
||||
if (bytes.size() < 9)
|
||||
return;
|
||||
int pos = 0;
|
||||
d->type = static_cast<Type>(bytes[0]);
|
||||
size_t pos = 0;
|
||||
d->data->type = static_cast<Type>(bytes[0]);
|
||||
++pos;
|
||||
const unsigned int dataLen = bytes.toUInt(pos, false);
|
||||
const unsigned int dataLen = bytes.toUInt32LE(pos);
|
||||
pos += 4;
|
||||
|
||||
const ByteVector nullStringTerminator(2, 0);
|
||||
|
||||
int endPos = bytes.find(nullStringTerminator, pos, 2);
|
||||
if (endPos < 0)
|
||||
size_t endPos = bytes.find(nullStringTerminator, pos, 2);
|
||||
if (endPos == ByteVector::npos())
|
||||
return;
|
||||
d->mimeType = String(bytes.mid(pos, endPos - pos), String::UTF16LE);
|
||||
d->data->mimeType = String(bytes.mid(pos, endPos - pos), String::UTF16LE);
|
||||
pos = endPos + 2;
|
||||
|
||||
endPos = bytes.find(nullStringTerminator, pos, 2);
|
||||
if (endPos < 0)
|
||||
if (endPos == ByteVector::npos())
|
||||
return;
|
||||
d->description = String(bytes.mid(pos, endPos - pos), String::UTF16LE);
|
||||
d->data->description = String(bytes.mid(pos, endPos - pos), String::UTF16LE);
|
||||
pos = endPos + 2;
|
||||
|
||||
if (dataLen + pos != bytes.size())
|
||||
return;
|
||||
|
||||
d->picture = bytes.mid(pos, dataLen);
|
||||
d->valid = true;
|
||||
d->data->picture = bytes.mid(pos, dataLen);
|
||||
d->data->valid = true;
|
||||
|
||||
}
|
||||
|
||||
ASF::Picture ASF::Picture::fromInvalid() {
|
||||
|
||||
Picture ret;
|
||||
ret.d->valid = false;
|
||||
ret.d->data->valid = false;
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
7
3rdparty/taglib/asf/asfpicture.h
vendored
7
3rdparty/taglib/asf/asfpicture.h
vendored
@ -34,6 +34,7 @@
|
||||
namespace Strawberry_TagLib {
|
||||
namespace TagLib {
|
||||
namespace ASF {
|
||||
class Attribute;
|
||||
|
||||
//! An ASF attached picture interface implementation
|
||||
|
||||
@ -200,11 +201,11 @@ class TAGLIB_EXPORT Picture {
|
||||
*/
|
||||
int dataSize() const;
|
||||
|
||||
#ifndef DO_NOT_DOCUMENT
|
||||
/* THIS IS PRIVATE, DON'T TOUCH IT! */
|
||||
private:
|
||||
friend class Attribute;
|
||||
|
||||
void parse(const ByteVector&);
|
||||
static Picture fromInvalid();
|
||||
#endif
|
||||
|
||||
private:
|
||||
class PicturePrivate;
|
||||
|
21
3rdparty/taglib/asf/asfproperties.cpp
vendored
21
3rdparty/taglib/asf/asfproperties.cpp
vendored
@ -23,21 +23,21 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tdebug.h>
|
||||
#include <tstring.h>
|
||||
#include "tdebug.h"
|
||||
#include "tstring.h"
|
||||
#include "asfproperties.h"
|
||||
|
||||
using namespace Strawberry_TagLib::TagLib;
|
||||
|
||||
class ASF::AudioProperties::AudioPropertiesPrivate {
|
||||
public:
|
||||
AudioPropertiesPrivate() : length(0),
|
||||
bitrate(0),
|
||||
sampleRate(0),
|
||||
channels(0),
|
||||
bitsPerSample(0),
|
||||
codec(ASF::AudioProperties::Unknown),
|
||||
encrypted(false) {}
|
||||
explicit AudioPropertiesPrivate() : length(0),
|
||||
bitrate(0),
|
||||
sampleRate(0),
|
||||
channels(0),
|
||||
bitsPerSample(0),
|
||||
codec(ASF::AudioProperties::Unknown),
|
||||
encrypted(false) {}
|
||||
|
||||
int length;
|
||||
int bitrate;
|
||||
@ -54,8 +54,7 @@ class ASF::AudioProperties::AudioPropertiesPrivate {
|
||||
// public members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ASF::AudioProperties::AudioProperties() : Strawberry_TagLib::TagLib::AudioProperties(AudioProperties::Average),
|
||||
d(new AudioPropertiesPrivate()) {
|
||||
ASF::AudioProperties::AudioProperties() : Strawberry_TagLib::TagLib::AudioProperties(), d(new AudioPropertiesPrivate()) {
|
||||
}
|
||||
|
||||
ASF::AudioProperties::~AudioProperties() {
|
||||
|
17
3rdparty/taglib/asf/asfproperties.h
vendored
17
3rdparty/taglib/asf/asfproperties.h
vendored
@ -36,6 +36,8 @@ namespace ASF {
|
||||
|
||||
//! An implementation of ASF audio properties
|
||||
class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioProperties {
|
||||
friend class File;
|
||||
|
||||
public:
|
||||
/*!
|
||||
* Audio codec types can be used in ASF file.
|
||||
@ -75,7 +77,7 @@ class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioPro
|
||||
/*!
|
||||
* Destroys this ASF::AudioProperties instance.
|
||||
*/
|
||||
virtual ~AudioProperties();
|
||||
~AudioProperties() override;
|
||||
|
||||
/*!
|
||||
* Returns the length of the file in seconds. The length is rounded down to
|
||||
@ -83,29 +85,29 @@ class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioPro
|
||||
*
|
||||
* \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.
|
||||
@ -142,7 +144,7 @@ class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioPro
|
||||
*/
|
||||
bool isEncrypted() const;
|
||||
|
||||
#ifndef DO_NOT_DOCUMENT
|
||||
private:
|
||||
void setLengthInMilliseconds(int value);
|
||||
void setBitrate(int value);
|
||||
void setSampleRate(int value);
|
||||
@ -152,7 +154,6 @@ class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioPro
|
||||
void setCodecName(const String &value);
|
||||
void setCodecDescription(const String &value);
|
||||
void setEncrypted(bool value);
|
||||
#endif
|
||||
|
||||
private:
|
||||
class AudioPropertiesPrivate;
|
||||
|
171
3rdparty/taglib/asf/asftag.cpp
vendored
171
3rdparty/taglib/asf/asftag.cpp
vendored
@ -23,7 +23,8 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tpropertymap.h>
|
||||
#include "tpicturemap.h"
|
||||
#include "tpropertymap.h"
|
||||
#include "asftag.h"
|
||||
|
||||
using namespace Strawberry_TagLib::TagLib;
|
||||
@ -38,8 +39,7 @@ class ASF::Tag::TagPrivate {
|
||||
AttributeListMap attributeListMap;
|
||||
};
|
||||
|
||||
ASF::Tag::Tag() : d(new TagPrivate()) {
|
||||
}
|
||||
ASF::Tag::Tag() : d(new TagPrivate()) {}
|
||||
|
||||
ASF::Tag::~Tag() {
|
||||
delete d;
|
||||
@ -104,6 +104,87 @@ String ASF::Tag::genre() const {
|
||||
|
||||
}
|
||||
|
||||
PictureMap ASF::Tag::pictures() const {
|
||||
|
||||
PictureMap map;
|
||||
if (d->attributeListMap.contains("WM/Picture")) {
|
||||
AttributeList list = d->attributeListMap["WM/Picture"];
|
||||
for (AttributeList::ConstIterator it = list.begin(); it != list.end(); ++it) {
|
||||
ASF::Picture asfPicture = (*it).toPicture();
|
||||
TagLib::Picture::Type type;
|
||||
switch (asfPicture.type()) {
|
||||
case ASF::Picture::FileIcon:
|
||||
type = TagLib::Picture::FileIcon;
|
||||
break;
|
||||
case ASF::Picture::OtherFileIcon:
|
||||
type = TagLib::Picture::OtherFileIcon;
|
||||
break;
|
||||
case ASF::Picture::FrontCover:
|
||||
type = TagLib::Picture::FrontCover;
|
||||
break;
|
||||
case ASF::Picture::BackCover:
|
||||
type = TagLib::Picture::BackCover;
|
||||
break;
|
||||
case ASF::Picture::LeafletPage:
|
||||
type = TagLib::Picture::LeafletPage;
|
||||
break;
|
||||
case ASF::Picture::Media:
|
||||
type = TagLib::Picture::Media;
|
||||
break;
|
||||
case ASF::Picture::LeadArtist:
|
||||
type = TagLib::Picture::LeadArtist;
|
||||
break;
|
||||
case ASF::Picture::Artist:
|
||||
type = TagLib::Picture::Artist;
|
||||
break;
|
||||
case ASF::Picture::Conductor:
|
||||
type = TagLib::Picture::Conductor;
|
||||
break;
|
||||
case ASF::Picture::Band:
|
||||
type = TagLib::Picture::Band;
|
||||
break;
|
||||
case ASF::Picture::Composer:
|
||||
type = TagLib::Picture::Composer;
|
||||
break;
|
||||
case ASF::Picture::Lyricist:
|
||||
type = TagLib::Picture::Lyricist;
|
||||
break;
|
||||
case ASF::Picture::RecordingLocation:
|
||||
type = TagLib::Picture::RecordingLocation;
|
||||
break;
|
||||
case ASF::Picture::DuringRecording:
|
||||
type = TagLib::Picture::DuringRecording;
|
||||
break;
|
||||
case ASF::Picture::DuringPerformance:
|
||||
type = TagLib::Picture::DuringPerformance;
|
||||
break;
|
||||
case ASF::Picture::MovieScreenCapture:
|
||||
type = TagLib::Picture::MovieScreenCapture;
|
||||
break;
|
||||
case ASF::Picture::ColouredFish:
|
||||
type = TagLib::Picture::ColouredFish;
|
||||
break;
|
||||
case ASF::Picture::Illustration:
|
||||
type = TagLib::Picture::Illustration;
|
||||
break;
|
||||
case ASF::Picture::BandLogo:
|
||||
type = TagLib::Picture::BandLogo;
|
||||
break;
|
||||
case ASF::Picture::PublisherLogo:
|
||||
type = TagLib::Picture::PublisherLogo;
|
||||
break;
|
||||
default:
|
||||
type = TagLib::Picture::Other;
|
||||
break;
|
||||
}
|
||||
TagLib::Picture picture(asfPicture.picture(), type, asfPicture.mimeType(), asfPicture.description());
|
||||
map.insert(picture);
|
||||
}
|
||||
}
|
||||
return PictureMap(map);
|
||||
|
||||
}
|
||||
|
||||
void ASF::Tag::setTitle(const String &value) {
|
||||
d->title = value;
|
||||
}
|
||||
@ -140,7 +221,89 @@ void ASF::Tag::setTrack(unsigned int value) {
|
||||
setAttribute("WM/TrackNumber", String::number(value));
|
||||
}
|
||||
|
||||
const ASF::AttributeListMap ASF::Tag::attributeListMap() const {
|
||||
void ASF::Tag::setPictures(const PictureMap &l) {
|
||||
|
||||
removeItem("WM/Picture");
|
||||
for (PictureMap::ConstIterator pictureMapIt = l.begin(); pictureMapIt != l.end(); ++pictureMapIt) {
|
||||
PictureList list = pictureMapIt->second;
|
||||
for (PictureList::ConstIterator pictureListIt = list.begin(); pictureListIt != list.end(); ++pictureListIt) {
|
||||
const TagLib::Picture picture = (*pictureListIt);
|
||||
ASF::Picture asfPicture;
|
||||
asfPicture.setPicture(picture.data());
|
||||
asfPicture.setMimeType(picture.mime());
|
||||
asfPicture.setDescription(picture.description());
|
||||
switch (picture.type()) {
|
||||
case TagLib::Picture::Other:
|
||||
asfPicture.setType(ASF::Picture::Other);
|
||||
break;
|
||||
case TagLib::Picture::FileIcon:
|
||||
asfPicture.setType(ASF::Picture::FileIcon);
|
||||
break;
|
||||
case TagLib::Picture::OtherFileIcon:
|
||||
asfPicture.setType(ASF::Picture::OtherFileIcon);
|
||||
break;
|
||||
case TagLib::Picture::FrontCover:
|
||||
asfPicture.setType(ASF::Picture::FrontCover);
|
||||
break;
|
||||
case TagLib::Picture::BackCover:
|
||||
asfPicture.setType(ASF::Picture::BackCover);
|
||||
break;
|
||||
case TagLib::Picture::LeafletPage:
|
||||
asfPicture.setType(ASF::Picture::LeafletPage);
|
||||
break;
|
||||
case TagLib::Picture::Media:
|
||||
asfPicture.setType(ASF::Picture::Media);
|
||||
break;
|
||||
case TagLib::Picture::LeadArtist:
|
||||
asfPicture.setType(ASF::Picture::LeadArtist);
|
||||
break;
|
||||
case TagLib::Picture::Artist:
|
||||
asfPicture.setType(ASF::Picture::Artist);
|
||||
break;
|
||||
case TagLib::Picture::Conductor:
|
||||
asfPicture.setType(ASF::Picture::Conductor);
|
||||
break;
|
||||
case TagLib::Picture::Band:
|
||||
asfPicture.setType(ASF::Picture::Band);
|
||||
break;
|
||||
case TagLib::Picture::Composer:
|
||||
asfPicture.setType(ASF::Picture::Composer);
|
||||
break;
|
||||
case TagLib::Picture::Lyricist:
|
||||
asfPicture.setType(ASF::Picture::Lyricist);
|
||||
break;
|
||||
case TagLib::Picture::RecordingLocation:
|
||||
asfPicture.setType(ASF::Picture::RecordingLocation);
|
||||
break;
|
||||
case TagLib::Picture::DuringRecording:
|
||||
asfPicture.setType(ASF::Picture::DuringRecording);
|
||||
break;
|
||||
case TagLib::Picture::DuringPerformance:
|
||||
asfPicture.setType(ASF::Picture::DuringPerformance);
|
||||
break;
|
||||
case TagLib::Picture::MovieScreenCapture:
|
||||
asfPicture.setType(ASF::Picture::MovieScreenCapture);
|
||||
break;
|
||||
case TagLib::Picture::ColouredFish:
|
||||
asfPicture.setType(ASF::Picture::ColouredFish);
|
||||
break;
|
||||
case TagLib::Picture::Illustration:
|
||||
asfPicture.setType(ASF::Picture::Illustration);
|
||||
break;
|
||||
case TagLib::Picture::BandLogo:
|
||||
asfPicture.setType(ASF::Picture::BandLogo);
|
||||
break;
|
||||
case TagLib::Picture::PublisherLogo:
|
||||
asfPicture.setType(ASF::Picture::PublisherLogo);
|
||||
break;
|
||||
}
|
||||
addAttribute("WM/Picture", Attribute(asfPicture));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const ASF::AttributeListMap &ASF::Tag::attributeListMap() const {
|
||||
return d->attributeListMap;
|
||||
}
|
||||
|
||||
|
46
3rdparty/taglib/asf/asftag.h
vendored
46
3rdparty/taglib/asf/asftag.h
vendored
@ -47,32 +47,32 @@ class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||
public:
|
||||
explicit Tag();
|
||||
|
||||
virtual ~Tag();
|
||||
~Tag() override;
|
||||
|
||||
/*!
|
||||
* Returns the track name.
|
||||
*/
|
||||
virtual String title() const;
|
||||
String title() const override;
|
||||
|
||||
/*!
|
||||
* Returns the artist name.
|
||||
*/
|
||||
virtual String artist() const;
|
||||
String artist() const override;
|
||||
|
||||
/*!
|
||||
* Returns the album name; if no album name is present in the tag String::null will be returned.
|
||||
*/
|
||||
virtual String album() const;
|
||||
String album() const override;
|
||||
|
||||
/*!
|
||||
* Returns the track comment.
|
||||
*/
|
||||
virtual String comment() const;
|
||||
String comment() const override;
|
||||
|
||||
/*!
|
||||
* Returns the genre name; if no genre is present in the tag String::null will be returned.
|
||||
*/
|
||||
virtual String genre() const;
|
||||
String genre() const override;
|
||||
|
||||
/*!
|
||||
* Returns the rating.
|
||||
@ -87,32 +87,34 @@ class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||
/*!
|
||||
* Returns the year; if there is no year set, this will return 0.
|
||||
*/
|
||||
virtual unsigned int year() const;
|
||||
unsigned int year() const override;
|
||||
|
||||
/*!
|
||||
* Returns the track number; if there is no track number set, this will return 0.
|
||||
*/
|
||||
virtual unsigned int track() const;
|
||||
unsigned int track() const override;
|
||||
|
||||
PictureMap pictures() const override;
|
||||
|
||||
/*!
|
||||
* Sets the title to \a s.
|
||||
*/
|
||||
virtual void setTitle(const String &value);
|
||||
void setTitle(const String &value) override;
|
||||
|
||||
/*!
|
||||
* Sets the artist to \a s.
|
||||
*/
|
||||
virtual void setArtist(const String &value);
|
||||
void setArtist(const String &value) override;
|
||||
|
||||
/*!
|
||||
* Sets the album to \a s. If \a s is String::null then this value will be cleared.
|
||||
*/
|
||||
virtual void setAlbum(const String &value);
|
||||
void setAlbum(const String &value) override;
|
||||
|
||||
/*!
|
||||
* Sets the comment to \a s.
|
||||
*/
|
||||
virtual void setComment(const String &value);
|
||||
void setComment(const String &value) override;
|
||||
|
||||
/*!
|
||||
* Sets the rating to \a s.
|
||||
@ -127,28 +129,30 @@ class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||
/*!
|
||||
* Sets the genre to \a s.
|
||||
*/
|
||||
virtual void setGenre(const String &value);
|
||||
void setGenre(const String &value) override;
|
||||
|
||||
/*!
|
||||
* Sets the year to \a i. If \a s is 0 then this value will be cleared.
|
||||
*/
|
||||
virtual void setYear(unsigned int value);
|
||||
void setYear(unsigned int value) override;
|
||||
|
||||
/*!
|
||||
* Sets the track to \a i. If \a s is 0 then this value will be cleared.
|
||||
*/
|
||||
virtual void setTrack(unsigned int value);
|
||||
void setTrack(unsigned int value) override;
|
||||
|
||||
void setPictures(const PictureMap&) override;
|
||||
|
||||
/*!
|
||||
* 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;
|
||||
bool isEmpty() const override;
|
||||
|
||||
/*!
|
||||
* Returns a reference to the item list map. This is an AttributeListMap of all of the items in the tag.
|
||||
*/
|
||||
const AttributeListMap attributeListMap() const;
|
||||
const AttributeListMap &attributeListMap() const;
|
||||
|
||||
/*!
|
||||
* \return True if a value for \a attribute is currently set.
|
||||
@ -181,15 +185,17 @@ class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||
*/
|
||||
void addAttribute(const String &name, const Attribute &attribute);
|
||||
|
||||
PropertyMap properties() const;
|
||||
void removeUnsupportedProperties(const StringList &props);
|
||||
PropertyMap setProperties(const PropertyMap &props);
|
||||
PropertyMap properties() const override;
|
||||
void removeUnsupportedProperties(const StringList &props) override;
|
||||
PropertyMap setProperties(const PropertyMap &props) override;
|
||||
|
||||
private:
|
||||
class TagPrivate;
|
||||
TagPrivate *d;
|
||||
};
|
||||
|
||||
} // namespace ASF
|
||||
} // namespace TagLib
|
||||
} // namespace Strawberry_TagLib
|
||||
|
||||
#endif
|
||||
|
20
3rdparty/taglib/asf/asfutils.h
vendored
20
3rdparty/taglib/asf/asfutils.h
vendored
@ -35,39 +35,40 @@ namespace TagLib {
|
||||
namespace ASF {
|
||||
namespace {
|
||||
|
||||
inline unsigned short readWORD(File *file, bool *ok = 0) {
|
||||
inline unsigned short readWORD(File *file, bool *ok = nullptr) {
|
||||
const ByteVector v = file->readBlock(2);
|
||||
if (v.size() != 2) {
|
||||
if (ok) *ok = false;
|
||||
return 0;
|
||||
}
|
||||
if (ok) *ok = true;
|
||||
return v.toUShort(false);
|
||||
return v.toUInt16LE(0);
|
||||
}
|
||||
|
||||
inline unsigned int readDWORD(File *file, bool *ok = 0) {
|
||||
inline unsigned int readDWORD(File *file, bool *ok = nullptr) {
|
||||
const ByteVector v = file->readBlock(4);
|
||||
if (v.size() != 4) {
|
||||
if (ok) *ok = false;
|
||||
return 0;
|
||||
}
|
||||
if (ok) *ok = true;
|
||||
return v.toUInt(false);
|
||||
return v.toUInt32LE(0);
|
||||
}
|
||||
|
||||
inline long long readQWORD(File *file, bool *ok = 0) {
|
||||
inline long long readQWORD(File *file, bool *ok = nullptr) {
|
||||
const ByteVector v = file->readBlock(8);
|
||||
if (v.size() != 8) {
|
||||
if (ok) *ok = false;
|
||||
return 0;
|
||||
}
|
||||
if (ok) *ok = true;
|
||||
return v.toLongLong(false);
|
||||
return v.toInt64LE(0);
|
||||
}
|
||||
|
||||
inline String readString(File *file, int length) {
|
||||
|
||||
ByteVector data = file->readBlock(length);
|
||||
unsigned int size = data.size();
|
||||
size_t size = data.size();
|
||||
while (size >= 2) {
|
||||
if (data[size - 1] != '\0' || data[size - 2] != '\0') {
|
||||
break;
|
||||
@ -78,12 +79,13 @@ inline String readString(File *file, int length) {
|
||||
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);
|
||||
ByteVector data = str.data(String::UTF16LE) + ByteVector::fromUInt16LE(0);
|
||||
if (includeLength) {
|
||||
data = ByteVector::fromShort(data.size(), false) + data;
|
||||
data = ByteVector::fromUInt16LE(data.size()) + data;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
2
3rdparty/taglib/audioproperties.cpp
vendored
2
3rdparty/taglib/audioproperties.cpp
vendored
@ -50,4 +50,4 @@ String AudioProperties::toString() const {
|
||||
// protected methods
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
AudioProperties::AudioProperties(ReadStyle) : d(nullptr) {}
|
||||
AudioProperties::AudioProperties() : d(nullptr) {}
|
||||
|
7
3rdparty/taglib/audioproperties.h
vendored
7
3rdparty/taglib/audioproperties.h
vendored
@ -27,6 +27,7 @@
|
||||
#define TAGLIB_AUDIOPROPERTIES_H
|
||||
|
||||
#include "taglib_export.h"
|
||||
#include "tstring.h"
|
||||
|
||||
namespace Strawberry_TagLib {
|
||||
namespace TagLib {
|
||||
@ -102,13 +103,11 @@ class TAGLIB_EXPORT AudioProperties {
|
||||
* 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
|
||||
*/
|
||||
explicit AudioProperties(ReadStyle style);
|
||||
explicit AudioProperties();
|
||||
|
||||
private:
|
||||
explicit AudioProperties(const AudioProperties&);
|
||||
AudioProperties(const AudioProperties&);
|
||||
AudioProperties &operator=(const AudioProperties&);
|
||||
|
||||
class AudioPropertiesPrivate;
|
||||
|
17
3rdparty/taglib/dsdiff/dsdiffdiintag.cpp
vendored
17
3rdparty/taglib/dsdiff/dsdiffdiintag.cpp
vendored
@ -26,6 +26,7 @@
|
||||
#include "dsdiffdiintag.h"
|
||||
#include "tstringlist.h"
|
||||
#include "tpropertymap.h"
|
||||
#include "tpicturemap.h"
|
||||
|
||||
using namespace Strawberry_TagLib::TagLib;
|
||||
using namespace DSDIFF::DIIN;
|
||||
@ -75,21 +76,19 @@ unsigned int DSDIFF::DIIN::Tag::track() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
PictureMap DSDIFF::DIIN::Tag::pictures() const {
|
||||
return PictureMap();
|
||||
}
|
||||
|
||||
void DSDIFF::DIIN::Tag::setTitle(const String &title) {
|
||||
|
||||
if (title.isEmpty())
|
||||
d->title = String();
|
||||
else
|
||||
d->title = title;
|
||||
d->title = title;
|
||||
|
||||
}
|
||||
|
||||
void DSDIFF::DIIN::Tag::setArtist(const String &artist) {
|
||||
|
||||
if (artist.isEmpty())
|
||||
d->artist = String();
|
||||
else
|
||||
d->artist = artist;
|
||||
d->artist = artist;
|
||||
|
||||
}
|
||||
|
||||
@ -103,6 +102,8 @@ void DSDIFF::DIIN::Tag::setYear(unsigned int) {}
|
||||
|
||||
void DSDIFF::DIIN::Tag::setTrack(unsigned int) {}
|
||||
|
||||
void DSDIFF::DIIN::Tag::setPictures(const PictureMap&) {}
|
||||
|
||||
PropertyMap DSDIFF::DIIN::Tag::properties() const {
|
||||
|
||||
PropertyMap properties;
|
||||
|
46
3rdparty/taglib/dsdiff/dsdiffdiintag.h
vendored
46
3rdparty/taglib/dsdiff/dsdiffdiintag.h
vendored
@ -42,83 +42,93 @@ namespace DIIN {
|
||||
class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||
public:
|
||||
explicit Tag();
|
||||
virtual ~Tag();
|
||||
~Tag() override;
|
||||
|
||||
/*!
|
||||
* Returns the track name; if no track name is present in the tag String() will be returned.
|
||||
*/
|
||||
String title() const;
|
||||
String title() const override;
|
||||
|
||||
/*!
|
||||
* Returns the artist name; if no artist name is present in the tag String() will be returned.
|
||||
*/
|
||||
String artist() const;
|
||||
String artist() const override;
|
||||
|
||||
/*!
|
||||
* Not supported. Therefore always returns String().
|
||||
*/
|
||||
String album() const;
|
||||
String album() const override;
|
||||
|
||||
/*!
|
||||
* Not supported. Therefore always returns String().
|
||||
*/
|
||||
String comment() const;
|
||||
String comment() const override;
|
||||
|
||||
/*!
|
||||
* Not supported. Therefore always returns String().
|
||||
*/
|
||||
String genre() const;
|
||||
String genre() const override;
|
||||
|
||||
/*!
|
||||
* Not supported. Therefore always returns 0.
|
||||
*/
|
||||
unsigned int year() const;
|
||||
unsigned int year() const override;
|
||||
|
||||
/*!
|
||||
* Not supported. Therefore always returns 0.
|
||||
*/
|
||||
unsigned int track() const;
|
||||
unsigned int track() const override;
|
||||
|
||||
/*!
|
||||
* Not supported. Therefore always returns an empty list.
|
||||
*/
|
||||
PictureMap pictures() const override;
|
||||
|
||||
/*!
|
||||
* 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) override;
|
||||
|
||||
/*!
|
||||
* 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) override;
|
||||
|
||||
/*!
|
||||
* Not supported and therefore ignored.
|
||||
*/
|
||||
void setAlbum(const String &album);
|
||||
void setAlbum(const String &album) override;
|
||||
|
||||
/*!
|
||||
* Not supported and therefore ignored.
|
||||
*/
|
||||
void setComment(const String &comment);
|
||||
void setComment(const String &comment) override;
|
||||
|
||||
/*!
|
||||
* Not supported and therefore ignored.
|
||||
*/
|
||||
void setGenre(const String &genre);
|
||||
void setGenre(const String &genre) override;
|
||||
|
||||
/*!
|
||||
* Not supported and therefore ignored.
|
||||
*/
|
||||
void setYear(unsigned int year);
|
||||
void setYear(unsigned int year) override;
|
||||
|
||||
/*!
|
||||
* Not supported and therefore ignored.
|
||||
*/
|
||||
void setTrack(unsigned int track);
|
||||
void setTrack(unsigned int track) override;
|
||||
|
||||
/*!
|
||||
* Not supported and therefore ignored.
|
||||
*/
|
||||
void setPictures(const PictureMap&) override;
|
||||
|
||||
/*!
|
||||
* 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 override;
|
||||
|
||||
/*!
|
||||
* Implements the unified property interface -- import function.
|
||||
@ -127,10 +137,10 @@ class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||
* Additionally, if the map contains tags with multiple values,
|
||||
* all but the first will be contained in the returned map of unsupported properties.
|
||||
*/
|
||||
PropertyMap setProperties(const PropertyMap &);
|
||||
PropertyMap setProperties(const PropertyMap &) override;
|
||||
|
||||
private:
|
||||
explicit Tag(const Tag &);
|
||||
Tag(const Tag &);
|
||||
Tag &operator=(const Tag &);
|
||||
|
||||
class TagPrivate;
|
||||
|
132
3rdparty/taglib/dsdiff/dsdifffile.cpp
vendored
132
3rdparty/taglib/dsdiff/dsdifffile.cpp
vendored
@ -23,19 +23,20 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tstring.h>
|
||||
#include <tbytevector.h>
|
||||
#include <tdebug.h>
|
||||
#include <id3v2tag.h>
|
||||
#include <tstringlist.h>
|
||||
#include <tpropertymap.h>
|
||||
#include <tagutils.h>
|
||||
#include <memory>
|
||||
#include <array>
|
||||
|
||||
#include "tstring.h"
|
||||
#include "tbytevector.h"
|
||||
#include "tdebug.h"
|
||||
#include "id3v2tag.h"
|
||||
#include "tstringlist.h"
|
||||
#include "tpropertymap.h"
|
||||
#include "tagutils.h"
|
||||
|
||||
#include "tagunion.h"
|
||||
#include "dsdifffile.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
using namespace Strawberry_TagLib::TagLib;
|
||||
|
||||
namespace {
|
||||
@ -89,7 +90,6 @@ class DSDIFF::File::FilePrivate {
|
||||
size(0),
|
||||
isID3InPropChunk(false),
|
||||
duplicateID3V2chunkIndex(-1),
|
||||
properties(nullptr),
|
||||
id3v2TagChunkID("ID3 "),
|
||||
hasID3v2(false),
|
||||
hasDiin(false) {
|
||||
@ -97,10 +97,6 @@ class DSDIFF::File::FilePrivate {
|
||||
childChunkIndex[DIINIndex] = -1;
|
||||
}
|
||||
|
||||
~FilePrivate() {
|
||||
delete properties;
|
||||
}
|
||||
|
||||
Endianness endianness;
|
||||
ByteVector type;
|
||||
unsigned long long size;
|
||||
@ -118,9 +114,9 @@ class DSDIFF::File::FilePrivate {
|
||||
*/
|
||||
int duplicateID3V2chunkIndex;
|
||||
|
||||
AudioProperties *properties;
|
||||
std::unique_ptr<AudioProperties> properties;
|
||||
|
||||
TagUnion tag;
|
||||
DoubleTagUnion tag;
|
||||
|
||||
ByteVector id3v2TagChunkID;
|
||||
|
||||
@ -211,7 +207,7 @@ PropertyMap DSDIFF::File::setProperties(const PropertyMap &properties) {
|
||||
}
|
||||
|
||||
DSDIFF::AudioProperties *DSDIFF::File::audioProperties() const {
|
||||
return d->properties;
|
||||
return d->properties.get();
|
||||
}
|
||||
|
||||
bool DSDIFF::File::save() {
|
||||
@ -269,7 +265,10 @@ bool DSDIFF::File::save(TagTypes tags, StripTags, ID3v2::Version version) {
|
||||
if (tags & DIIN && diinTag) {
|
||||
if (!diinTag->title().isEmpty()) {
|
||||
ByteVector diinTitle;
|
||||
diinTitle.append(ByteVector::fromUInt(diinTag->title().size(), d->endianness == BigEndian));
|
||||
if (d->endianness == BigEndian)
|
||||
diinTitle.append(ByteVector::fromUInt32BE(diinTag->title().size()));
|
||||
else
|
||||
diinTitle.append(ByteVector::fromUInt32LE(diinTag->title().size()));
|
||||
diinTitle.append(ByteVector::fromCString(diinTag->title().toCString()));
|
||||
setChildChunkData("DITI", diinTitle, DIINChunk);
|
||||
}
|
||||
@ -278,7 +277,10 @@ bool DSDIFF::File::save(TagTypes tags, StripTags, ID3v2::Version version) {
|
||||
|
||||
if (!diinTag->artist().isEmpty()) {
|
||||
ByteVector diinArtist;
|
||||
diinArtist.append(ByteVector::fromUInt(diinTag->artist().size(), d->endianness == BigEndian));
|
||||
if (d->endianness == BigEndian)
|
||||
diinArtist.append(ByteVector::fromUInt32BE(diinTag->artist().size()));
|
||||
else
|
||||
diinArtist.append(ByteVector::fromUInt32LE(diinTag->artist().size()));
|
||||
diinArtist.append(ByteVector::fromCString(diinTag->artist().toCString()));
|
||||
setChildChunkData("DIAR", diinArtist, DIINChunk);
|
||||
}
|
||||
@ -324,7 +326,10 @@ 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);
|
||||
if (d->endianness == BigEndian)
|
||||
insert(ByteVector::fromUInt64BE(d->size), 4, 8);
|
||||
else
|
||||
insert(ByteVector::fromUInt64LE(d->size), 4, 8);
|
||||
|
||||
removeBlock(d->chunks[i].offset - 12, chunkSize);
|
||||
|
||||
@ -357,14 +362,14 @@ void DSDIFF::File::setRootChunkData(unsigned int i, const ByteVector &data) {
|
||||
// First we update the global size
|
||||
|
||||
d->size += ((data.size() + 1) & ~1) - (d->chunks[i].size + d->chunks[i].padding);
|
||||
insert(ByteVector::fromLongLong(d->size, d->endianness == BigEndian), 4, 8);
|
||||
if (d->endianness == BigEndian)
|
||||
insert(ByteVector::fromUInt64BE(d->size), 4, 8);
|
||||
else
|
||||
insert(ByteVector::fromUInt64LE(d->size), 4, 8);
|
||||
|
||||
// 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);
|
||||
writeChunk(d->chunks[i].name, 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;
|
||||
@ -395,7 +400,10 @@ void DSDIFF::File::setRootChunkData(const ByteVector &name, const ByteVector &da
|
||||
|
||||
// First we update the global size
|
||||
d->size += (offset & 1) + ((data.size() + 1) & ~1) + 12;
|
||||
insert(ByteVector::fromLongLong(d->size, d->endianness == BigEndian), 4, 8);
|
||||
if (d->endianness == BigEndian)
|
||||
insert(ByteVector::fromUInt64BE(d->size), 4, 8);
|
||||
else
|
||||
insert(ByteVector::fromUInt64LE(d->size), 4, 8);
|
||||
|
||||
// Now add the chunk to the file
|
||||
writeChunk(name,
|
||||
@ -422,14 +430,18 @@ void DSDIFF::File::removeChildChunk(unsigned int i, unsigned int childChunkNum)
|
||||
|
||||
unsigned long long removedChunkTotalSize = childChunks[i].size + childChunks[i].padding + 12;
|
||||
d->size -= removedChunkTotalSize;
|
||||
insert(ByteVector::fromLongLong(d->size, d->endianness == BigEndian), 4, 8);
|
||||
if (d->endianness == BigEndian)
|
||||
insert(ByteVector::fromUInt64BE(d->size), 4, 8);
|
||||
else
|
||||
insert(ByteVector::fromUInt64LE(d->size), 4, 8);
|
||||
|
||||
// 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);
|
||||
if (d->endianness == BigEndian)
|
||||
insert(ByteVector::fromUInt64BE(d->chunks[d->childChunkIndex[childChunkNum]].size), d->chunks[d->childChunkIndex[childChunkNum]].offset - 8, 8);
|
||||
else
|
||||
insert(ByteVector::fromUInt64LE(d->chunks[d->childChunkIndex[childChunkNum]].size), d->chunks[d->childChunkIndex[childChunkNum]].offset - 8, 8);
|
||||
// Remove the chunk
|
||||
|
||||
removeBlock(childChunks[i].offset - 12, removedChunkTotalSize);
|
||||
@ -467,19 +479,23 @@ void DSDIFF::File::setChildChunkData(unsigned int i, const ByteVector &data, uns
|
||||
|
||||
d->size += ((data.size() + 1) & ~1) - (childChunks[i].size + childChunks[i].padding);
|
||||
|
||||
insert(ByteVector::fromLongLong(d->size, d->endianness == BigEndian), 4, 8);
|
||||
if (d->endianness == BigEndian)
|
||||
insert(ByteVector::fromUInt64BE(d->size), 4, 8);
|
||||
else
|
||||
insert(ByteVector::fromUInt64LE(d->size), 4, 8);
|
||||
|
||||
// And the PROP chunk size
|
||||
|
||||
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);
|
||||
|
||||
if (d->endianness == BigEndian)
|
||||
insert(ByteVector::fromUInt64BE(d->chunks[d->childChunkIndex[childChunkNum]].size), d->chunks[d->childChunkIndex[childChunkNum]].offset - 8, 8);
|
||||
else
|
||||
insert(ByteVector::fromUInt64LE(d->chunks[d->childChunkIndex[childChunkNum]].size), 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);
|
||||
writeChunk(childChunks[i].name, 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;
|
||||
@ -523,14 +539,18 @@ void DSDIFF::File::setChildChunkData(const ByteVector &name, const ByteVector &d
|
||||
// First we update the global size
|
||||
|
||||
d->size += (offset & 1) + ((data.size() + 1) & ~1) + 12;
|
||||
insert(ByteVector::fromLongLong(d->size, d->endianness == BigEndian), 4, 8);
|
||||
if (d->endianness == BigEndian)
|
||||
insert(ByteVector::fromUInt64BE(d->size), 4, 8);
|
||||
else
|
||||
insert(ByteVector::fromUInt64LE(d->size), 4, 8);
|
||||
|
||||
// And the child chunk size
|
||||
|
||||
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);
|
||||
if (d->endianness == BigEndian)
|
||||
insert(ByteVector::fromUInt64BE(d->chunks[d->childChunkIndex[childChunkNum]].size), d->chunks[d->childChunkIndex[childChunkNum]].offset - 8, 8);
|
||||
else
|
||||
insert(ByteVector::fromUInt64LE(d->chunks[d->childChunkIndex[childChunkNum]].size), d->chunks[d->childChunkIndex[childChunkNum]].offset - 8, 8);
|
||||
|
||||
// Now add the chunk to the file
|
||||
|
||||
@ -587,14 +607,14 @@ void DSDIFF::File::read(bool readProperties, AudioProperties::ReadStyle properti
|
||||
bool bigEndian = (d->endianness == BigEndian);
|
||||
|
||||
d->type = readBlock(4);
|
||||
d->size = readBlock(8).toLongLong(bigEndian);
|
||||
d->size = bigEndian ? readBlock(8).toInt64BE(0) : readBlock(8).toInt64LE(0);
|
||||
d->format = readBlock(4);
|
||||
|
||||
// + 12: chunk header at least, fix for additional junk bytes
|
||||
|
||||
while (tell() + 12 <= length()) {
|
||||
ByteVector chunkName = readBlock(4);
|
||||
unsigned long long chunkSize = readBlock(8).toLongLong(bigEndian);
|
||||
unsigned long long chunkSize = bigEndian ? readBlock(8).toInt64BE(0) : readBlock(8).toInt64LE(0);
|
||||
|
||||
if (!isValidChunkID(chunkName)) {
|
||||
debug("DSDIFF::File::read() -- Chunk '" + chunkName + "' has invalid ID");
|
||||
@ -654,7 +674,7 @@ void DSDIFF::File::read(bool readProperties, AudioProperties::ReadStyle properti
|
||||
|
||||
while (tell() + 12 <= dstChunkEnd) {
|
||||
ByteVector dstChunkName = readBlock(4);
|
||||
long long dstChunkSize = readBlock(8).toLongLong(bigEndian);
|
||||
long long dstChunkSize = bigEndian ? readBlock(8).toInt64BE(0) : readBlock(8).toInt64LE(0);
|
||||
|
||||
if (!isValidChunkID(dstChunkName)) {
|
||||
debug("DSDIFF::File::read() -- DST Chunk '" + dstChunkName + "' has invalid ID");
|
||||
@ -670,8 +690,8 @@ void DSDIFF::File::read(bool readProperties, AudioProperties::ReadStyle properti
|
||||
|
||||
if (dstChunkName == "FRTE") {
|
||||
// Found the DST frame information chunk
|
||||
dstNumFrames = readBlock(4).toUInt(bigEndian);
|
||||
dstFrameRate = readBlock(2).toUShort(bigEndian);
|
||||
dstNumFrames = bigEndian ? readBlock(4).toUInt32BE(0) : readBlock(4).toUInt32LE(0);
|
||||
dstFrameRate = bigEndian ? readBlock(2).toUInt16BE(0) : readBlock(2).toUInt16LE(0);
|
||||
// Found the wanted one, no need to look at the others
|
||||
break;
|
||||
}
|
||||
@ -696,7 +716,7 @@ void DSDIFF::File::read(bool readProperties, AudioProperties::ReadStyle properti
|
||||
seek(d->chunks[i].offset + 4);
|
||||
while (tell() + 12 <= propChunkEnd) {
|
||||
ByteVector propChunkName = readBlock(4);
|
||||
long long propChunkSize = readBlock(8).toLongLong(bigEndian);
|
||||
long long propChunkSize = bigEndian ? readBlock(8).toInt64BE(0) : readBlock(8).toInt64LE(0);
|
||||
|
||||
if (!isValidChunkID(propChunkName)) {
|
||||
debug("DSDIFF::File::read() -- PROP Chunk '" + propChunkName + "' has invalid ID");
|
||||
@ -742,7 +762,7 @@ void DSDIFF::File::read(bool readProperties, AudioProperties::ReadStyle properti
|
||||
|
||||
while (tell() + 12 <= diinChunkEnd) {
|
||||
ByteVector diinChunkName = readBlock(4);
|
||||
long long diinChunkSize = readBlock(8).toLongLong(bigEndian);
|
||||
long long diinChunkSize = bigEndian ? readBlock(8).toInt64BE(0) : readBlock(8).toInt64LE(0);
|
||||
|
||||
if (!isValidChunkID(diinChunkName)) {
|
||||
debug("DSDIFF::File::read() -- DIIN Chunk '" + diinChunkName + "' has invalid ID");
|
||||
@ -802,8 +822,7 @@ void DSDIFF::File::read(bool readProperties, AudioProperties::ReadStyle properti
|
||||
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->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
|
||||
@ -817,12 +836,12 @@ void DSDIFF::File::read(bool readProperties, AudioProperties::ReadStyle properti
|
||||
else if (d->childChunks[PROPChunk][i].name == "FS ") {
|
||||
// Sample rate
|
||||
seek(d->childChunks[PROPChunk][i].offset);
|
||||
sampleRate = readBlock(4).toUInt(0, 4, bigEndian);
|
||||
sampleRate = bigEndian ? readBlock(4).toUInt32BE(0) : readBlock(4).toUInt32LE(0);
|
||||
}
|
||||
else if (d->childChunks[PROPChunk][i].name == "CHNL") {
|
||||
// Channels
|
||||
seek(d->childChunks[PROPChunk][i].offset);
|
||||
channels = readBlock(2).toShort(0, bigEndian);
|
||||
channels = bigEndian ? readBlock(2).toInt16BE(0) : readBlock(2).toInt16LE(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -834,7 +853,7 @@ void DSDIFF::File::read(bool readProperties, AudioProperties::ReadStyle properti
|
||||
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);
|
||||
unsigned int titleStrLength = bigEndian ? readBlock(4).toUInt32BE(0) : readBlock(4).toUInt32LE(0);
|
||||
if (titleStrLength <= d->childChunks[DIINChunk][i].size) {
|
||||
ByteVector titleStr = readBlock(titleStrLength);
|
||||
d->tag.access<DSDIFF::DIIN::Tag>(DIINIndex, false)->setTitle(titleStr);
|
||||
@ -842,7 +861,7 @@ void DSDIFF::File::read(bool readProperties, AudioProperties::ReadStyle properti
|
||||
}
|
||||
else if (d->childChunks[DIINChunk][i].name == "DIAR") {
|
||||
seek(d->childChunks[DIINChunk][i].offset);
|
||||
unsigned int artistStrLength = readBlock(4).toUInt(0, 4, bigEndian);
|
||||
unsigned int artistStrLength = bigEndian ? readBlock(4).toUInt32BE(0) : readBlock(4).toUInt32LE(0);
|
||||
if (artistStrLength <= d->childChunks[DIINChunk][i].size) {
|
||||
ByteVector artistStr = readBlock(artistStrLength);
|
||||
d->tag.access<DSDIFF::DIIN::Tag>(DIINIndex, false)->setArtist(artistStr);
|
||||
@ -868,7 +887,7 @@ void DSDIFF::File::read(bool readProperties, AudioProperties::ReadStyle properti
|
||||
if (lengthDSDSamplesTimeChannels > 0)
|
||||
bitrate = (audioDataSizeinBytes * 8 * sampleRate) / lengthDSDSamplesTimeChannels / 1000;
|
||||
|
||||
d->properties = new AudioProperties(sampleRate, channels, lengthDSDSamplesTimeChannels, bitrate, propertiesStyle);
|
||||
d->properties.reset(new AudioProperties(sampleRate, channels, lengthDSDSamplesTimeChannels, bitrate, propertiesStyle));
|
||||
}
|
||||
|
||||
if (!ID3v2Tag()) {
|
||||
@ -887,7 +906,10 @@ void DSDIFF::File::writeChunk(const ByteVector &name, const ByteVector &data, un
|
||||
combined.append(ByteVector(leadingPadding, '\x00'));
|
||||
|
||||
combined.append(name);
|
||||
combined.append(ByteVector::fromLongLong(data.size(), d->endianness == BigEndian));
|
||||
if (d->endianness == BigEndian)
|
||||
combined.append(ByteVector::fromUInt64BE(data.size()));
|
||||
else
|
||||
combined.append(ByteVector::fromUInt64LE(data.size()));
|
||||
combined.append(data);
|
||||
if ((data.size() & 0x01) != 0)
|
||||
combined.append('\x00');
|
||||
|
16
3rdparty/taglib/dsdiff/dsdifffile.h
vendored
16
3rdparty/taglib/dsdiff/dsdifffile.h
vendored
@ -95,7 +95,7 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
|
||||
/*!
|
||||
* Destroys this instance of the File.
|
||||
*/
|
||||
virtual ~File();
|
||||
~File() override;
|
||||
|
||||
/*!
|
||||
* Returns a pointer to a tag that is the union of the ID3v2 and DIIN tags.
|
||||
@ -110,7 +110,7 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
|
||||
* \see ID3v2Tag()
|
||||
* \see DIINTag()
|
||||
*/
|
||||
virtual Tag *tag() const;
|
||||
Tag *tag() const override;
|
||||
|
||||
/*!
|
||||
* Returns the ID3V2 Tag for this file.
|
||||
@ -132,21 +132,21 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
|
||||
* Implements the unified property interface -- export function.
|
||||
* This method forwards to ID3v2::Tag::properties().
|
||||
*/
|
||||
PropertyMap properties() const;
|
||||
PropertyMap properties() const override;
|
||||
|
||||
void removeUnsupportedProperties(const StringList &properties);
|
||||
void removeUnsupportedProperties(const StringList &properties) override;
|
||||
|
||||
/*!
|
||||
* Implements the unified property interface -- import function.
|
||||
* This method forwards to ID3v2::Tag::setProperties().
|
||||
*/
|
||||
PropertyMap setProperties(const PropertyMap &properties);
|
||||
PropertyMap setProperties(const PropertyMap &properties) override;
|
||||
|
||||
/*!
|
||||
* Returns the AIFF::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. If at least one tag -- ID3v1 or DIIN -- exists this will duplicate its content into the other tag.
|
||||
@ -161,7 +161,7 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
|
||||
*
|
||||
* \see save(int tags)
|
||||
*/
|
||||
virtual bool save();
|
||||
bool save() override;
|
||||
|
||||
/*!
|
||||
* Save the file. If \a strip is specified,
|
||||
@ -209,7 +209,7 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
|
||||
File(IOStream *stream, Endianness endianness);
|
||||
|
||||
private:
|
||||
explicit File(const File &);
|
||||
File(const File &);
|
||||
File &operator=(const File &);
|
||||
|
||||
void removeRootChunk(const ByteVector &id);
|
||||
|
20
3rdparty/taglib/dsdiff/dsdiffproperties.cpp
vendored
20
3rdparty/taglib/dsdiff/dsdiffproperties.cpp
vendored
@ -23,8 +23,8 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tstring.h>
|
||||
#include <tdebug.h>
|
||||
#include "tstring.h"
|
||||
#include "tdebug.h"
|
||||
|
||||
#include "dsdiffproperties.h"
|
||||
|
||||
@ -32,12 +32,12 @@ using namespace Strawberry_TagLib::TagLib;
|
||||
|
||||
class DSDIFF::AudioProperties::AudioPropertiesPrivate {
|
||||
public:
|
||||
AudioPropertiesPrivate() : length(0),
|
||||
bitrate(0),
|
||||
sampleRate(0),
|
||||
channels(0),
|
||||
sampleWidth(0),
|
||||
sampleCount(0) {
|
||||
explicit AudioPropertiesPrivate() : length(0),
|
||||
bitrate(0),
|
||||
sampleRate(0),
|
||||
channels(0),
|
||||
sampleWidth(0),
|
||||
sampleCount(0) {
|
||||
}
|
||||
|
||||
int length;
|
||||
@ -52,9 +52,7 @@ class DSDIFF::AudioProperties::AudioPropertiesPrivate {
|
||||
// public members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DSDIFF::AudioProperties::AudioProperties(const unsigned int sampleRate, const unsigned short channels, const unsigned long long samplesCount, const int bitrate, ReadStyle style) : Strawberry_TagLib::TagLib::AudioProperties(style) {
|
||||
|
||||
d = new AudioPropertiesPrivate;
|
||||
DSDIFF::AudioProperties::AudioProperties(const unsigned int sampleRate, const unsigned short channels, const unsigned long long samplesCount, const int bitrate, ReadStyle) : Strawberry_TagLib::TagLib::AudioProperties(), d(new AudioPropertiesPrivate) {
|
||||
|
||||
d->channels = channels;
|
||||
d->sampleCount = samplesCount;
|
||||
|
16
3rdparty/taglib/dsdiff/dsdiffproperties.h
vendored
16
3rdparty/taglib/dsdiff/dsdiffproperties.h
vendored
@ -45,26 +45,26 @@ class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioPro
|
||||
/*!
|
||||
* Create an instance of DSDIFF::AudioProperties with the data read from the ByteVector \a data.
|
||||
*/
|
||||
explicit AudioProperties(const unsigned int sampleRate, const unsigned short channels, const unsigned long long samplesCount, const int bitrate, ReadStyle style);
|
||||
explicit AudioProperties(const unsigned int sampleRate, const unsigned short channels, const unsigned long long samplesCount, const int bitrate, ReadStyle);
|
||||
|
||||
/*!
|
||||
* Destroys this DSDIFF::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 bitsPerSample() const;
|
||||
long long sampleCount() const;
|
||||
|
||||
private:
|
||||
explicit AudioProperties(const AudioProperties &);
|
||||
AudioProperties(const AudioProperties &);
|
||||
AudioProperties &operator=(const AudioProperties &);
|
||||
|
||||
class AudioPropertiesPrivate;
|
||||
|
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);
|
||||
|
193
3rdparty/taglib/fileref.cpp
vendored
193
3rdparty/taglib/fileref.cpp
vendored
@ -27,11 +27,12 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <tfile.h>
|
||||
#include <tfilestream.h>
|
||||
#include <tstring.h>
|
||||
#include <tdebug.h>
|
||||
#include <trefcounter.h>
|
||||
|
||||
#include "fileref.h"
|
||||
#include "asffile.h"
|
||||
@ -58,7 +59,7 @@
|
||||
using namespace Strawberry_TagLib::TagLib;
|
||||
|
||||
namespace {
|
||||
typedef List<const FileRef::FileTypeResolver *> ResolverList;
|
||||
typedef List<const FileRef::FileTypeResolver*> ResolverList;
|
||||
ResolverList fileTypeResolvers;
|
||||
|
||||
// Detect the file type by user-defined resolvers.
|
||||
@ -81,14 +82,14 @@ File *detectByResolvers(FileName fileName, bool readAudioProperties, AudioProper
|
||||
File *detectByExtension(IOStream *stream, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle) {
|
||||
|
||||
#ifdef _WIN32
|
||||
const String s = stream->name().toString();
|
||||
const String s(stream->name().wstr());
|
||||
#else
|
||||
const String s(stream->name());
|
||||
#endif
|
||||
|
||||
String ext;
|
||||
const int pos = s.rfind(".");
|
||||
if (pos != -1)
|
||||
const size_t pos = s.rfind(".");
|
||||
if (pos != String::npos())
|
||||
ext = s.substr(pos + 1).upper();
|
||||
|
||||
// If this list is updated, the method defaultFileExtensions() should also be
|
||||
@ -105,7 +106,7 @@ File *detectByExtension(IOStream *stream, bool readAudioProperties, AudioPropert
|
||||
if (ext == "OGG")
|
||||
return new Ogg::Vorbis::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||
if (ext == "FLAC")
|
||||
return new FLAC::File(stream, ID3v2::FrameFactory::instance(), readAudioProperties, audioPropertiesStyle);
|
||||
return new FLAC::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||
if (ext == "MPC")
|
||||
return new MPC::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||
if (ext == "WV")
|
||||
@ -157,7 +158,7 @@ File *detectByContent(IOStream *stream, bool readAudioProperties, AudioPropertie
|
||||
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);
|
||||
file = new FLAC::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||
else if (MPC::File::isSupported(stream))
|
||||
file = new MPC::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||
else if (WavPack::File::isSupported(stream))
|
||||
@ -196,87 +197,10 @@ File *detectByContent(IOStream *stream, bool readAudioProperties, AudioPropertie
|
||||
|
||||
}
|
||||
|
||||
// Internal function that supports FileRef::create().
|
||||
// This looks redundant, but necessary in order not to change the previous
|
||||
// behavior of FileRef::create().
|
||||
struct FileRefData {
|
||||
FileRefData() : file(nullptr), stream(nullptr) {}
|
||||
|
||||
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() : file(nullptr), stream(nullptr) {}
|
||||
|
||||
~FileRefPrivate() override {
|
||||
~FileRefData() {
|
||||
delete file;
|
||||
delete stream;
|
||||
}
|
||||
@ -285,6 +209,15 @@ class FileRef::FileRefPrivate : public RefCounter {
|
||||
IOStream *stream;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
class FileRef::FileRefPrivate {
|
||||
public:
|
||||
FileRefPrivate() : data(new FileRefData()) {}
|
||||
|
||||
std::shared_ptr<FileRefData> data;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// public members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -300,18 +233,13 @@ FileRef::FileRef(IOStream *stream, bool readAudioProperties, AudioProperties::Re
|
||||
}
|
||||
|
||||
FileRef::FileRef(File *file) : d(new FileRefPrivate()) {
|
||||
d->file = file;
|
||||
d->data->file = file;
|
||||
}
|
||||
|
||||
FileRef::FileRef(const FileRef &ref) : d(ref.d) {
|
||||
d->ref();
|
||||
}
|
||||
FileRef::FileRef(const FileRef &ref) : d(new FileRefPrivate(*ref.d)) {}
|
||||
|
||||
FileRef::~FileRef() {
|
||||
|
||||
if (d->deref())
|
||||
delete d;
|
||||
|
||||
delete d;
|
||||
}
|
||||
|
||||
Tag *FileRef::tag() const {
|
||||
@ -320,22 +248,50 @@ Tag *FileRef::tag() const {
|
||||
debug("FileRef::tag() - Called without a valid file.");
|
||||
return nullptr;
|
||||
}
|
||||
return d->file->tag();
|
||||
return d->data->file->tag();
|
||||
|
||||
}
|
||||
|
||||
PropertyMap FileRef::properties() const {
|
||||
if (isNull()) {
|
||||
debug("FileRef::properties() - Called without a valid file.");
|
||||
return PropertyMap();
|
||||
}
|
||||
|
||||
return d->data->file->properties();
|
||||
}
|
||||
|
||||
void FileRef::removeUnsupportedProperties(const StringList &properties) {
|
||||
if (isNull()) {
|
||||
debug("FileRef::removeUnsupportedProperties() - Called without a valid file.");
|
||||
return;
|
||||
}
|
||||
|
||||
d->data->file->removeUnsupportedProperties(properties);
|
||||
}
|
||||
|
||||
|
||||
PropertyMap FileRef::setProperties(const PropertyMap &properties) {
|
||||
if (isNull()) {
|
||||
debug("FileRef::setProperties() - Called without a valid file.");
|
||||
return PropertyMap();
|
||||
}
|
||||
|
||||
return d->data->file->setProperties(properties);
|
||||
}
|
||||
|
||||
AudioProperties *FileRef::audioProperties() const {
|
||||
|
||||
if (isNull()) {
|
||||
debug("FileRef::audioProperties() - Called without a valid file.");
|
||||
return nullptr;
|
||||
}
|
||||
return d->file->audioProperties();
|
||||
return d->data->file->audioProperties();
|
||||
|
||||
}
|
||||
|
||||
File *FileRef::file() const {
|
||||
return d->file;
|
||||
return d->data->file;
|
||||
}
|
||||
|
||||
bool FileRef::save() {
|
||||
@ -344,7 +300,7 @@ bool FileRef::save() {
|
||||
debug("FileRef::save() - Called without a valid file.");
|
||||
return false;
|
||||
}
|
||||
return d->file->save();
|
||||
return d->data->file->save();
|
||||
|
||||
}
|
||||
|
||||
@ -393,8 +349,12 @@ StringList FileRef::defaultFileExtensions() {
|
||||
|
||||
}
|
||||
|
||||
bool FileRef::isValid() const {
|
||||
return (d->data->file && d->data->file->isValid());
|
||||
}
|
||||
|
||||
bool FileRef::isNull() const {
|
||||
return (!d->file || !d->file->isValid());
|
||||
return (!d->data->file || !d->data->file->isValid());
|
||||
}
|
||||
|
||||
FileRef &FileRef::operator=(const FileRef &ref) {
|
||||
@ -409,15 +369,11 @@ void FileRef::swap(FileRef &ref) {
|
||||
}
|
||||
|
||||
bool FileRef::operator==(const FileRef &ref) const {
|
||||
return (ref.d->file == d->file);
|
||||
return (ref.d->data == d->data);
|
||||
}
|
||||
|
||||
bool FileRef::operator!=(const FileRef &ref) const {
|
||||
return (ref.d->file != d->file);
|
||||
}
|
||||
|
||||
File *FileRef::create(FileName fileName, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle) { // static
|
||||
return createInternal(fileName, readAudioProperties, audioPropertiesStyle);
|
||||
return (ref.d->data != d->data);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -428,28 +384,27 @@ void FileRef::parse(FileName fileName, bool readAudioProperties, AudioProperties
|
||||
|
||||
// Try user-defined resolvers.
|
||||
|
||||
d->file = detectByResolvers(fileName, readAudioProperties, audioPropertiesStyle);
|
||||
if (d->file)
|
||||
d->data->file = detectByResolvers(fileName, readAudioProperties, audioPropertiesStyle);
|
||||
if (d->data->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)
|
||||
d->data->stream = new FileStream(fileName);
|
||||
d->data->file = detectByExtension(d->data->stream, readAudioProperties, audioPropertiesStyle);
|
||||
if (d->data->file)
|
||||
return;
|
||||
|
||||
// At last, try to resolve file types based on the actual content.
|
||||
|
||||
d->file = detectByContent(d->stream, readAudioProperties, audioPropertiesStyle);
|
||||
if (d->file)
|
||||
d->data->file = detectByContent(d->data->stream, readAudioProperties, audioPropertiesStyle);
|
||||
if (d->data->file)
|
||||
return;
|
||||
|
||||
// Stream have to be closed here if failed to resolve file types.
|
||||
|
||||
delete d->stream;
|
||||
d->stream = nullptr;
|
||||
|
||||
delete d->data->stream;
|
||||
d->data->stream = nullptr;
|
||||
}
|
||||
|
||||
void FileRef::parse(IOStream *stream, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle) {
|
||||
@ -458,12 +413,12 @@ void FileRef::parse(IOStream *stream, bool readAudioProperties, AudioProperties:
|
||||
|
||||
// Try to resolve file types based on the file extension.
|
||||
|
||||
d->file = detectByExtension(stream, readAudioProperties, audioPropertiesStyle);
|
||||
if (d->file)
|
||||
d->data->file = detectByExtension(stream, readAudioProperties, audioPropertiesStyle);
|
||||
if (d->data->file)
|
||||
return;
|
||||
|
||||
// At last, try to resolve file types based on the actual content of the file.
|
||||
|
||||
d->file = detectByContent(stream, readAudioProperties, audioPropertiesStyle);
|
||||
d->data->file = detectByContent(stream, readAudioProperties, audioPropertiesStyle);
|
||||
|
||||
}
|
||||
|
49
3rdparty/taglib/fileref.h
vendored
49
3rdparty/taglib/fileref.h
vendored
@ -30,6 +30,7 @@
|
||||
#include "tstringlist.h"
|
||||
|
||||
#include "taglib_export.h"
|
||||
#include "tpropertymap.h"
|
||||
#include "audioproperties.h"
|
||||
|
||||
namespace Strawberry_TagLib {
|
||||
@ -85,7 +86,7 @@ class TAGLIB_EXPORT FileRef {
|
||||
|
||||
class TAGLIB_EXPORT FileTypeResolver {
|
||||
public:
|
||||
virtual ~FileTypeResolver();
|
||||
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.
|
||||
@ -151,6 +152,34 @@ class TAGLIB_EXPORT FileRef {
|
||||
*/
|
||||
Tag *tag() const;
|
||||
|
||||
/*!
|
||||
* Exports the tags of the file as dictionary mapping (human readable) tag names (uppercase Strings) to StringLists of tag values.
|
||||
* Calls the according specialization in the File subclasses.
|
||||
* For each metadata object of the file that could not be parsed into the PropertyMap format,
|
||||
* the returend map's unsupportedData() list will contain one entry identifying that object (e.g. the frame type for ID3v2 tags).
|
||||
* Use removeUnsupportedProperties() to remove (a subset of) them.
|
||||
* For files that contain more than one tag (e.g. an MP3 with both an ID3v1 and an ID3v2 tag) only the most "modern" one will be exported (ID3v2 in this case).
|
||||
*/
|
||||
PropertyMap properties() const;
|
||||
|
||||
/*!
|
||||
* Removes unsupported properties, or a subset of them, from the file's metadata.
|
||||
* The parameter \a properties must contain only entries from properties().unsupportedData().
|
||||
*/
|
||||
void removeUnsupportedProperties(const StringList &properties);
|
||||
|
||||
/*!
|
||||
* Sets the tags of this File to those specified in \a properties.
|
||||
* Calls the according specialization method in the subclasses of File to do the translation into the format-specific details.
|
||||
* If some value(s) could not be written imported to the specific metadata format,
|
||||
* the returned PropertyMap will contain those value(s). Otherwise it will be empty, indicating that no problems occured.
|
||||
* With file types that support several tag formats (for instance, MP3 files can have ID3v1, ID3v2, and APEv2 tags),
|
||||
* this function will create the most appropriate one (ID3v2 for MP3 files). Older formats will be updated as well,
|
||||
* if they exist, but won't be taken into account for the return value of this function.
|
||||
* See the documentation of the subclass implementations for detailed descriptions.
|
||||
*/
|
||||
PropertyMap setProperties(const PropertyMap &properties);
|
||||
|
||||
/*!
|
||||
* Returns the audio properties for this FileRef.
|
||||
* If no audio properties were read then this will returns a null pointer.
|
||||
@ -208,6 +237,13 @@ class TAGLIB_EXPORT FileRef {
|
||||
*/
|
||||
static StringList defaultFileExtensions();
|
||||
|
||||
/*!
|
||||
* Returns true if the file is open and readable.
|
||||
*
|
||||
* \note Just a negative of isNull().
|
||||
*/
|
||||
bool isValid() const;
|
||||
|
||||
/*!
|
||||
* Returns true if the file (and as such other pointers) are null.
|
||||
*/
|
||||
@ -233,17 +269,6 @@ class TAGLIB_EXPORT FileRef {
|
||||
*/
|
||||
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 \a audioPropertiesStyle will be ignored.
|
||||
*
|
||||
* \note You generally shouldn't use this method, but instead the constructor directly.
|
||||
*
|
||||
* \deprecated
|
||||
*/
|
||||
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);
|
||||
|
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);
|
||||
|
18
3rdparty/taglib/it/itfile.cpp
vendored
18
3rdparty/taglib/it/itfile.cpp
vendored
@ -41,16 +41,14 @@ class IT::File::FilePrivate {
|
||||
IT::AudioProperties properties;
|
||||
};
|
||||
|
||||
IT::File::File(FileName file, bool readProperties,
|
||||
AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(file), d(new FilePrivate(propertiesStyle)) {
|
||||
IT::File::File(FileName file, bool readProperties, 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)) {
|
||||
IT::File::File(IOStream *stream, bool readProperties, AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(stream), d(new FilePrivate(propertiesStyle)) {
|
||||
|
||||
if (isOpen())
|
||||
read(readProperties);
|
||||
@ -94,7 +92,7 @@ bool IT::File::save() {
|
||||
StringList lines = d->tag.comment().split("\n");
|
||||
for (unsigned short i = 0; i < instrumentCount; ++i) {
|
||||
seek(192L + length + (static_cast<long>(i) << 2));
|
||||
unsigned long instrumentOffset = 0;
|
||||
unsigned int instrumentOffset = 0;
|
||||
if (!readU32L(instrumentOffset))
|
||||
return false;
|
||||
|
||||
@ -109,7 +107,7 @@ bool IT::File::save() {
|
||||
|
||||
for (unsigned short i = 0; i < sampleCount; ++i) {
|
||||
seek(192L + length + (static_cast<long>(instrumentCount) << 2) + (static_cast<long>(i) << 2));
|
||||
unsigned long sampleOffset = 0;
|
||||
unsigned int sampleOffset = 0;
|
||||
if (!readU32L(sampleOffset))
|
||||
return false;
|
||||
|
||||
@ -136,13 +134,13 @@ bool IT::File::save() {
|
||||
|
||||
unsigned short special = 0;
|
||||
unsigned short messageLength = 0;
|
||||
unsigned long messageOffset = 0;
|
||||
unsigned int messageOffset = 0;
|
||||
|
||||
seek(46);
|
||||
if (!readU16L(special))
|
||||
return false;
|
||||
|
||||
unsigned long fileSize = File::length();
|
||||
unsigned int fileSize = File::length();
|
||||
if (special & AudioProperties::MessageAttached) {
|
||||
seek(54);
|
||||
if (!readU16L(messageLength) || !readU32L(messageOffset))
|
||||
@ -217,8 +215,8 @@ void IT::File::read(bool) {
|
||||
seek(messageOffset);
|
||||
ByteVector messageBytes = readBlock(messageLength);
|
||||
READ_ASSERT(messageBytes.size() == messageLength);
|
||||
int index = messageBytes.find(static_cast<char>(0));
|
||||
if (index > -1)
|
||||
const size_t index = messageBytes.find(static_cast<char>(0));
|
||||
if (index != ByteVector::npos())
|
||||
messageBytes.resize(index, 0);
|
||||
messageBytes.replace('\r', '\n');
|
||||
message = messageBytes;
|
||||
|
10
3rdparty/taglib/it/itfile.h
vendored
10
3rdparty/taglib/it/itfile.h
vendored
@ -56,15 +56,15 @@ class TAGLIB_EXPORT File : public Mod::FileBase {
|
||||
/*!
|
||||
* Destroys this instance of the File.
|
||||
*/
|
||||
virtual ~File();
|
||||
~File() override;
|
||||
|
||||
Mod::Tag *tag() const;
|
||||
Mod::Tag *tag() const override;
|
||||
|
||||
/*!
|
||||
* Returns the IT::AudioProperties for this file. If no audio properties
|
||||
* were read then this will return a null pointer.
|
||||
*/
|
||||
IT::AudioProperties *audioProperties() const;
|
||||
IT::AudioProperties *audioProperties() const override;
|
||||
|
||||
/*!
|
||||
* Save the file.
|
||||
@ -72,10 +72,10 @@ class TAGLIB_EXPORT File : public Mod::FileBase {
|
||||
*
|
||||
* \note Saving Impulse Tracker tags is not supported.
|
||||
*/
|
||||
bool save();
|
||||
bool save() override;
|
||||
|
||||
private:
|
||||
explicit File(const File&);
|
||||
File(const File&);
|
||||
File &operator=(const File&);
|
||||
|
||||
void read(bool readProperties);
|
||||
|
36
3rdparty/taglib/it/itproperties.cpp
vendored
36
3rdparty/taglib/it/itproperties.cpp
vendored
@ -31,21 +31,21 @@ using namespace IT;
|
||||
|
||||
class IT::AudioProperties::AudioPropertiesPrivate {
|
||||
public:
|
||||
AudioPropertiesPrivate() : 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) {
|
||||
explicit AudioPropertiesPrivate() : 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;
|
||||
@ -65,7 +65,7 @@ class IT::AudioProperties::AudioPropertiesPrivate {
|
||||
unsigned char pitchWheelDepth;
|
||||
};
|
||||
|
||||
IT::AudioProperties::AudioProperties(AudioProperties::ReadStyle propertiesStyle) : Strawberry_TagLib::TagLib::AudioProperties(propertiesStyle), d(new AudioPropertiesPrivate()) {}
|
||||
IT::AudioProperties::AudioProperties(AudioProperties::ReadStyle) : Strawberry_TagLib::TagLib::AudioProperties(), d(new AudioPropertiesPrivate()) {}
|
||||
|
||||
IT::AudioProperties::~AudioProperties() {
|
||||
delete d;
|
||||
@ -151,6 +151,10 @@ unsigned char IT::AudioProperties::pitchWheelDepth() const {
|
||||
return d->pitchWheelDepth;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// private members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void IT::AudioProperties::setChannels(int channels) {
|
||||
d->channels = channels;
|
||||
}
|
||||
|
18
3rdparty/taglib/it/itproperties.h
vendored
18
3rdparty/taglib/it/itproperties.h
vendored
@ -54,14 +54,14 @@ class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioPro
|
||||
MidiConfEmbedded = 8
|
||||
};
|
||||
|
||||
explicit AudioProperties(AudioProperties::ReadStyle propertiesStyle);
|
||||
virtual ~AudioProperties();
|
||||
explicit AudioProperties(AudioProperties::ReadStyle);
|
||||
~AudioProperties() override;
|
||||
|
||||
int lengthInSeconds() const;
|
||||
int lengthInMilliseconds() const;
|
||||
int bitrate() const;
|
||||
int sampleRate() const;
|
||||
int channels() const;
|
||||
int lengthInSeconds() const override;
|
||||
int lengthInMilliseconds() const override;
|
||||
int bitrate() const override;
|
||||
int sampleRate() const override;
|
||||
int channels() const override;
|
||||
|
||||
unsigned short lengthInPatterns() const;
|
||||
bool stereo() const;
|
||||
@ -79,6 +79,7 @@ class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioPro
|
||||
unsigned char panningSeparation() const;
|
||||
unsigned char pitchWheelDepth() const;
|
||||
|
||||
private:
|
||||
void setChannels(int channels);
|
||||
void setLengthInPatterns(unsigned short lengthInPatterns);
|
||||
void setInstrumentCount(unsigned short instrumentCount);
|
||||
@ -96,9 +97,6 @@ class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioPro
|
||||
void setPitchWheelDepth(unsigned char pitchWheelDepth);
|
||||
|
||||
private:
|
||||
explicit AudioProperties(const AudioProperties &);
|
||||
AudioProperties &operator=(const AudioProperties &);
|
||||
|
||||
class AudioPropertiesPrivate;
|
||||
AudioPropertiesPrivate *d;
|
||||
};
|
||||
|
14
3rdparty/taglib/mod/modfile.cpp
vendored
14
3rdparty/taglib/mod/modfile.cpp
vendored
@ -67,14 +67,6 @@ Mod::AudioProperties *Mod::File::audioProperties() const {
|
||||
return &d->properties;
|
||||
}
|
||||
|
||||
PropertyMap Mod::File::properties() const {
|
||||
return d->tag.properties();
|
||||
}
|
||||
|
||||
PropertyMap Mod::File::setProperties(const PropertyMap &properties) {
|
||||
return d->tag.setProperties(properties);
|
||||
}
|
||||
|
||||
bool Mod::File::save() {
|
||||
|
||||
if (readOnly()) {
|
||||
@ -84,13 +76,13 @@ bool Mod::File::save() {
|
||||
seek(0);
|
||||
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) {
|
||||
size_t n = std::min<size_t>(lines.size(), d->properties.instrumentCount());
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
writeString(lines[i], 22);
|
||||
seek(8, Current);
|
||||
}
|
||||
|
||||
for (unsigned int i = n; i < d->properties.instrumentCount(); ++i) {
|
||||
for (size_t i = n; i < d->properties.instrumentCount(); ++i) {
|
||||
writeString(String(), 22);
|
||||
seek(8, Current);
|
||||
}
|
||||
|
21
3rdparty/taglib/mod/modfile.h
vendored
21
3rdparty/taglib/mod/modfile.h
vendored
@ -61,25 +61,14 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::Mod::FileBase {
|
||||
/*!
|
||||
* Destroys this instance of the File.
|
||||
*/
|
||||
virtual ~File();
|
||||
~File() override;
|
||||
|
||||
Mod::Tag *tag() const;
|
||||
Mod::Tag *tag() const override;
|
||||
|
||||
/*!
|
||||
* Implements the unified property interface -- export function.
|
||||
* Forwards to Mod::Tag::properties().
|
||||
*/
|
||||
PropertyMap properties() const;
|
||||
|
||||
/*!
|
||||
* Implements the unified property interface -- import function.
|
||||
* Forwards to Mod::Tag::setProperties().
|
||||
*/
|
||||
PropertyMap setProperties(const PropertyMap &);
|
||||
/*!
|
||||
* Returns the Mod::AudioProperties for this file. If no audio properties were read then this will return a null pointer.
|
||||
*/
|
||||
Mod::AudioProperties *audioProperties() const;
|
||||
Mod::AudioProperties *audioProperties() const override;
|
||||
|
||||
/*!
|
||||
* Save the file.
|
||||
@ -87,10 +76,10 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::Mod::FileBase {
|
||||
*
|
||||
* \note Saving Protracker tags is not supported.
|
||||
*/
|
||||
bool save();
|
||||
bool save() override;
|
||||
|
||||
private:
|
||||
explicit File(const File &);
|
||||
File(const File &);
|
||||
File &operator=(const File &);
|
||||
|
||||
void read(bool readProperties);
|
||||
|
32
3rdparty/taglib/mod/modfilebase.cpp
vendored
32
3rdparty/taglib/mod/modfilebase.cpp
vendored
@ -34,18 +34,18 @@ Mod::FileBase::FileBase(FileName file) : Strawberry_TagLib::TagLib::File(file) {
|
||||
|
||||
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 int 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 int size) {
|
||||
|
||||
ByteVector data(readBlock(size));
|
||||
if (data.size() < size) return false;
|
||||
int index = data.find(static_cast<char>(0));
|
||||
if (index > -1) {
|
||||
const size_t index = data.find(static_cast<char>(0));
|
||||
if (index != ByteVector::npos()) {
|
||||
data.resize(index);
|
||||
}
|
||||
data.replace('\xff', ' ');
|
||||
@ -61,19 +61,19 @@ void Mod::FileBase::writeByte(unsigned char _byte) {
|
||||
}
|
||||
|
||||
void Mod::FileBase::writeU16L(unsigned short number) {
|
||||
writeBlock(ByteVector::fromShort(number, false));
|
||||
writeBlock(ByteVector::fromUInt16LE(number));
|
||||
}
|
||||
|
||||
void Mod::FileBase::writeU32L(unsigned long number) {
|
||||
writeBlock(ByteVector::fromUInt(number, false));
|
||||
void Mod::FileBase::writeU32L(unsigned int number) {
|
||||
writeBlock(ByteVector::fromUInt32LE(number));
|
||||
}
|
||||
|
||||
void Mod::FileBase::writeU16B(unsigned short number) {
|
||||
writeBlock(ByteVector::fromShort(number, true));
|
||||
writeBlock(ByteVector::fromUInt16BE(number));
|
||||
}
|
||||
|
||||
void Mod::FileBase::writeU32B(unsigned long number) {
|
||||
writeBlock(ByteVector::fromUInt(number, true));
|
||||
void Mod::FileBase::writeU32B(unsigned int number) {
|
||||
writeBlock(ByteVector::fromUInt32BE(number));
|
||||
}
|
||||
|
||||
bool Mod::FileBase::readByte(unsigned char &_byte) {
|
||||
@ -89,16 +89,16 @@ bool Mod::FileBase::readU16L(unsigned short &number) {
|
||||
|
||||
ByteVector data(readBlock(2));
|
||||
if (data.size() < 2) return false;
|
||||
number = data.toUShort(false);
|
||||
number = data.toUInt16LE(0);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
bool Mod::FileBase::readU32L(unsigned long &number) {
|
||||
bool Mod::FileBase::readU32L(unsigned int &number) {
|
||||
|
||||
ByteVector data(readBlock(4));
|
||||
if (data.size() < 4) return false;
|
||||
number = data.toUInt(false);
|
||||
number = data.toUInt32LE(0);
|
||||
return true;
|
||||
|
||||
}
|
||||
@ -107,16 +107,16 @@ bool Mod::FileBase::readU16B(unsigned short &number) {
|
||||
|
||||
ByteVector data(readBlock(2));
|
||||
if (data.size() < 2) return false;
|
||||
number = data.toUShort(true);
|
||||
number = data.toUInt16BE(0);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
bool Mod::FileBase::readU32B(unsigned long &number) {
|
||||
bool Mod::FileBase::readU32B(unsigned int &number) {
|
||||
|
||||
ByteVector data(readBlock(4));
|
||||
if (data.size() < 4) return false;
|
||||
number = data.toUInt(true);
|
||||
number = data.toUInt32BE(0);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
14
3rdparty/taglib/mod/modfilebase.h
vendored
14
3rdparty/taglib/mod/modfilebase.h
vendored
@ -43,19 +43,19 @@ class TAGLIB_EXPORT FileBase : public Strawberry_TagLib::TagLib::File {
|
||||
explicit FileBase(FileName file);
|
||||
explicit FileBase(IOStream *stream);
|
||||
|
||||
void writeString(const String &s, unsigned long size, char padding = 0);
|
||||
void writeString(const String &s, unsigned int size, char padding = 0);
|
||||
void writeByte(unsigned char byte);
|
||||
void writeU16L(unsigned short number);
|
||||
void writeU32L(unsigned long number);
|
||||
void writeU32L(unsigned int number);
|
||||
void writeU16B(unsigned short number);
|
||||
void writeU32B(unsigned long number);
|
||||
void writeU32B(unsigned int number);
|
||||
|
||||
bool readString(String &s, unsigned long size);
|
||||
bool readByte(unsigned char &byte);
|
||||
bool readString(String &s, unsigned int size);
|
||||
bool readByte(unsigned char &_byte);
|
||||
bool readU16L(unsigned short &number);
|
||||
bool readU32L(unsigned long &number);
|
||||
bool readU32L(unsigned int &number);
|
||||
bool readU16B(unsigned short &number);
|
||||
bool readU32B(unsigned long &number);
|
||||
bool readU32B(unsigned int &number);
|
||||
};
|
||||
|
||||
} // namespace Mod
|
||||
|
8
3rdparty/taglib/mod/modfileprivate.h
vendored
8
3rdparty/taglib/mod/modfileprivate.h
vendored
@ -38,9 +38,9 @@
|
||||
|
||||
#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_U32L(setter) READ(setter, unsigned int, readU32L)
|
||||
#define READ_U16B(setter) READ(setter, unsigned short, readU16B)
|
||||
#define READ_U32B(setter) READ(setter, unsigned long, readU32B)
|
||||
#define READ_U32B(setter) READ(setter, unsigned int, readU32B)
|
||||
|
||||
#define READ_STRING(setter, size) \
|
||||
{ \
|
||||
@ -55,9 +55,9 @@
|
||||
|
||||
#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_U32L_AS(name) READ_AS(unsigned int, 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_U32B_AS(name) READ_AS(unsigned int, name, readU32B)
|
||||
|
||||
#define READ_STRING_AS(name, size) \
|
||||
String name; \
|
||||
|
12
3rdparty/taglib/mod/modproperties.cpp
vendored
12
3rdparty/taglib/mod/modproperties.cpp
vendored
@ -31,14 +31,18 @@ using namespace Mod;
|
||||
|
||||
class Mod::AudioProperties::AudioPropertiesPrivate {
|
||||
public:
|
||||
AudioPropertiesPrivate() : channels(0), instrumentCount(0), lengthInPatterns(0) {}
|
||||
explicit AudioPropertiesPrivate() : channels(0), instrumentCount(0), lengthInPatterns(0) {}
|
||||
|
||||
int channels;
|
||||
unsigned int instrumentCount;
|
||||
unsigned char lengthInPatterns;
|
||||
};
|
||||
|
||||
Mod::AudioProperties::AudioProperties(AudioProperties::ReadStyle propertiesStyle) : Strawberry_TagLib::TagLib::AudioProperties(propertiesStyle), d(new AudioPropertiesPrivate()) {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// public members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Mod::AudioProperties::AudioProperties(AudioProperties::ReadStyle) : Strawberry_TagLib::TagLib::AudioProperties(), d(new AudioPropertiesPrivate()) {
|
||||
}
|
||||
|
||||
Mod::AudioProperties::~AudioProperties() {
|
||||
@ -73,6 +77,10 @@ unsigned char Mod::AudioProperties::lengthInPatterns() const {
|
||||
return d->lengthInPatterns;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// private members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Mod::AudioProperties::setChannels(int channels) {
|
||||
d->channels = channels;
|
||||
}
|
||||
|
21
3rdparty/taglib/mod/modproperties.h
vendored
21
3rdparty/taglib/mod/modproperties.h
vendored
@ -34,30 +34,27 @@ namespace TagLib {
|
||||
namespace Mod {
|
||||
|
||||
class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioProperties {
|
||||
friend class File;
|
||||
|
||||
public:
|
||||
explicit AudioProperties(AudioProperties::ReadStyle propertiesStyle);
|
||||
virtual ~AudioProperties();
|
||||
~AudioProperties() override;
|
||||
|
||||
int lengthInSeconds() const;
|
||||
int lengthInMilliseconds() const;
|
||||
int bitrate() const;
|
||||
int sampleRate() const;
|
||||
int channels() const;
|
||||
int lengthInSeconds() const override;
|
||||
int lengthInMilliseconds() const override;
|
||||
int bitrate() const override;
|
||||
int sampleRate() const override;
|
||||
int channels() const override;
|
||||
|
||||
unsigned int instrumentCount() const;
|
||||
unsigned char lengthInPatterns() const;
|
||||
|
||||
private:
|
||||
void setChannels(int channels);
|
||||
|
||||
void setInstrumentCount(unsigned int instrumentCount);
|
||||
void setLengthInPatterns(unsigned char lengthInPatterns);
|
||||
|
||||
private:
|
||||
friend class File;
|
||||
|
||||
explicit AudioProperties(const AudioProperties&);
|
||||
AudioProperties &operator=(const AudioProperties&);
|
||||
|
||||
class AudioPropertiesPrivate;
|
||||
AudioPropertiesPrivate *d;
|
||||
};
|
||||
|
9
3rdparty/taglib/mod/modtag.cpp
vendored
9
3rdparty/taglib/mod/modtag.cpp
vendored
@ -27,13 +27,14 @@
|
||||
#include "modtag.h"
|
||||
#include "tstringlist.h"
|
||||
#include "tpropertymap.h"
|
||||
#include "tpicturemap.h"
|
||||
|
||||
using namespace Strawberry_TagLib::TagLib;
|
||||
using namespace Mod;
|
||||
|
||||
class Mod::Tag::TagPrivate {
|
||||
public:
|
||||
TagPrivate() {}
|
||||
explicit TagPrivate() {}
|
||||
|
||||
String title;
|
||||
String comment;
|
||||
@ -74,6 +75,10 @@ unsigned int Mod::Tag::track() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Strawberry_TagLib::TagLib::PictureMap Mod::Tag::pictures() const {
|
||||
return PictureMap();
|
||||
}
|
||||
|
||||
String Mod::Tag::trackerName() const {
|
||||
return d->trackerName;
|
||||
}
|
||||
@ -101,6 +106,8 @@ void Mod::Tag::setYear(unsigned int) {
|
||||
void Mod::Tag::setTrack(unsigned int) {
|
||||
}
|
||||
|
||||
void Mod::Tag::setPictures(const PictureMap&) {}
|
||||
|
||||
void Mod::Tag::setTrackerName(const String &trackerName) {
|
||||
d->trackerName = trackerName;
|
||||
}
|
||||
|
40
3rdparty/taglib/mod/modtag.h
vendored
40
3rdparty/taglib/mod/modtag.h
vendored
@ -47,43 +47,45 @@ namespace Mod {
|
||||
class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||
public:
|
||||
explicit Tag();
|
||||
virtual ~Tag();
|
||||
~Tag() override;
|
||||
|
||||
/*!
|
||||
* Returns the track name; if no track name is present in the tag String::null will be returned.
|
||||
*/
|
||||
virtual String title() const;
|
||||
String title() const override;
|
||||
|
||||
/*!
|
||||
* Not supported by module files. Therefore always returns String::null.
|
||||
*/
|
||||
virtual String artist() const;
|
||||
String artist() const override;
|
||||
|
||||
/*!
|
||||
* Not supported by module files. Therefore always returns String::null.
|
||||
*/
|
||||
virtual String album() const;
|
||||
String album() const override;
|
||||
|
||||
/*!
|
||||
* 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;
|
||||
String comment() const override;
|
||||
|
||||
/*!
|
||||
* Not supported by module files. Therefore always returns String::null.
|
||||
*/
|
||||
virtual String genre() const;
|
||||
String genre() const override;
|
||||
|
||||
/*!
|
||||
* Not supported by module files. Therefore always returns 0.
|
||||
*/
|
||||
virtual unsigned int year() const;
|
||||
unsigned int year() const override;
|
||||
|
||||
/*!
|
||||
* Not supported by module files. Therefore always returns 0.
|
||||
*/
|
||||
virtual unsigned int track() const;
|
||||
unsigned int track() const override;
|
||||
|
||||
PictureMap pictures() const override;
|
||||
|
||||
/*!
|
||||
* Returns the name of the tracker used to create/edit the module file.
|
||||
@ -100,17 +102,17 @@ class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||
* The length limits per file type are (1 character = 1 byte):
|
||||
* Mod 20 characters, S3M 27 characters, IT 25 characters and XM 20 characters.
|
||||
*/
|
||||
virtual void setTitle(const String &title);
|
||||
void setTitle(const String &title) override;
|
||||
|
||||
/*!
|
||||
* Not supported by module files and therefore ignored.
|
||||
*/
|
||||
virtual void setArtist(const String &artist);
|
||||
void setArtist(const String &artist) override;
|
||||
|
||||
/*!
|
||||
* Not supported by module files and therefore ignored.
|
||||
*/
|
||||
virtual void setAlbum(const String &album);
|
||||
void setAlbum(const String &album) override;
|
||||
|
||||
/*!
|
||||
* Sets the comment to \a comment.
|
||||
@ -126,22 +128,24 @@ class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||
* The line length limits per file type are (1 character = 1 byte):
|
||||
* Mod 22 characters, S3M 27 characters, IT 25 characters and XM 22 characters.
|
||||
*/
|
||||
virtual void setComment(const String &comment);
|
||||
void setComment(const String &comment) override;
|
||||
|
||||
/*!
|
||||
* Not supported by module files and therefore ignored.
|
||||
*/
|
||||
virtual void setGenre(const String &genre);
|
||||
void setGenre(const String &genre) override;
|
||||
|
||||
/*!
|
||||
* Not supported by module files and therefore ignored.
|
||||
*/
|
||||
virtual void setYear(unsigned int year);
|
||||
void setYear(unsigned int year) override;
|
||||
|
||||
/*!
|
||||
* Not supported by module files and therefore ignored.
|
||||
*/
|
||||
virtual void setTrack(unsigned int track);
|
||||
void setTrack(unsigned int track) override;
|
||||
|
||||
void setPictures(const PictureMap &l) override;
|
||||
|
||||
/*!
|
||||
* Sets the tracker name to \a trackerName.
|
||||
@ -158,17 +162,17 @@ class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||
* 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 override;
|
||||
|
||||
/*!
|
||||
* 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 returned.
|
||||
* Additionally, if the map contains tags with multiple values, all but the first will be contained in the returned map of unsupported properties.
|
||||
*/
|
||||
PropertyMap setProperties(const PropertyMap &);
|
||||
PropertyMap setProperties(const PropertyMap &) override;
|
||||
|
||||
private:
|
||||
explicit Tag(const Tag&);
|
||||
Tag(const Tag&);
|
||||
Tag &operator=(const Tag&);
|
||||
|
||||
class TagPrivate;
|
||||
|
20
3rdparty/taglib/mp4/mp4atom.cpp
vendored
20
3rdparty/taglib/mp4/mp4atom.cpp
vendored
@ -25,8 +25,8 @@
|
||||
|
||||
#include <climits>
|
||||
|
||||
#include <tdebug.h>
|
||||
#include <tstring.h>
|
||||
#include "tdebug.h"
|
||||
#include "tstring.h"
|
||||
#include "mp4atom.h"
|
||||
|
||||
using namespace Strawberry_TagLib::TagLib;
|
||||
@ -48,7 +48,7 @@ MP4::Atom::Atom(File *file) {
|
||||
return;
|
||||
}
|
||||
|
||||
length = header.toUInt();
|
||||
length = header.toUInt32BE(0);
|
||||
|
||||
if (length == 0) {
|
||||
// The last atom which extends to the end of the file.
|
||||
@ -56,17 +56,7 @@ MP4::Atom::Atom(File *file) {
|
||||
}
|
||||
else if (length == 1) {
|
||||
// The atom has a 64-bit length.
|
||||
const long long longLength = file->readBlock(8).toLongLong();
|
||||
if (longLength <= LONG_MAX) {
|
||||
// The actual length fits in long. That's always the case if long is 64-bit.
|
||||
length = static_cast<long>(longLength);
|
||||
}
|
||||
else {
|
||||
debug("MP4: 64-bit atoms are not supported");
|
||||
length = 0;
|
||||
file->seek(0, File::End);
|
||||
return;
|
||||
}
|
||||
length = file->readBlock(8).toInt64BE(0);
|
||||
}
|
||||
|
||||
if (length < 8) {
|
||||
@ -151,7 +141,7 @@ MP4::Atoms::Atoms(File *file) {
|
||||
atoms.setAutoDelete(true);
|
||||
|
||||
file->seek(0, File::End);
|
||||
long end = file->tell();
|
||||
long long end = file->tell();
|
||||
file->seek(0);
|
||||
while (file->tell() + 8 <= end) {
|
||||
MP4::Atom *atom = new MP4::Atom(file);
|
||||
|
12
3rdparty/taglib/mp4/mp4atom.h
vendored
12
3rdparty/taglib/mp4/mp4atom.h
vendored
@ -78,11 +78,11 @@ class Atom {
|
||||
explicit 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);
|
||||
Atom *find(const char *name1, const char *name2 = nullptr, const char *name3 = nullptr, const char *name4 = nullptr);
|
||||
bool path(AtomList &path, const char *name1, const char *name2 = nullptr, const char *name3 = nullptr);
|
||||
AtomList findall(const char *name, bool recursive = false);
|
||||
long offset;
|
||||
long length;
|
||||
long long offset;
|
||||
long long length;
|
||||
Strawberry_TagLib::TagLib::ByteVector name;
|
||||
AtomList children;
|
||||
|
||||
@ -97,8 +97,8 @@ class Atoms {
|
||||
explicit 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);
|
||||
Atom *find(const char *name1, const char *name2 = nullptr, const char *name3 = nullptr, const char *name4 = nullptr);
|
||||
AtomList path(const char *name1, const char *name2 = nullptr, const char *name3 = nullptr, const char *name4 = nullptr);
|
||||
AtomList atoms;
|
||||
};
|
||||
|
||||
|
43
3rdparty/taglib/mp4/mp4coverart.cpp
vendored
43
3rdparty/taglib/mp4/mp4coverart.cpp
vendored
@ -23,33 +23,40 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <taglib.h>
|
||||
#include <tdebug.h>
|
||||
#include "trefcounter.h"
|
||||
#include <memory>
|
||||
|
||||
#include "taglib.h"
|
||||
#include "tdebug.h"
|
||||
#include "mp4coverart.h"
|
||||
|
||||
using namespace Strawberry_TagLib::TagLib;
|
||||
|
||||
class MP4::CoverArt::CoverArtPrivate : public RefCounter {
|
||||
public:
|
||||
CoverArtPrivate() : format(MP4::CoverArt::JPEG) {}
|
||||
namespace {
|
||||
|
||||
Format format;
|
||||
struct CoverArtData {
|
||||
MP4::CoverArt::Format format;
|
||||
ByteVector data;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
class MP4::CoverArt::CoverArtPrivate {
|
||||
public:
|
||||
explicit CoverArtPrivate(Format f, const ByteVector &v) : data(new CoverArtData()) {
|
||||
data->format = f;
|
||||
data->data = v;
|
||||
}
|
||||
|
||||
std::shared_ptr<CoverArtData> data;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// public members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
MP4::CoverArt::CoverArt(Format format, const ByteVector &data) : d(new CoverArtPrivate()) {
|
||||
d->format = format;
|
||||
d->data = data;
|
||||
}
|
||||
MP4::CoverArt::CoverArt(Format format, const ByteVector &data) : d(new CoverArtPrivate(format, data)) {}
|
||||
|
||||
MP4::CoverArt::CoverArt(const CoverArt &item) : d(item.d) {
|
||||
d->ref();
|
||||
}
|
||||
MP4::CoverArt::CoverArt(const CoverArt &item) : d(new CoverArtPrivate(*item.d)) {}
|
||||
|
||||
MP4::CoverArt &
|
||||
MP4::CoverArt::operator=(const CoverArt &item) {
|
||||
@ -64,17 +71,15 @@ void MP4::CoverArt::swap(CoverArt &item) {
|
||||
}
|
||||
|
||||
MP4::CoverArt::~CoverArt() {
|
||||
if (d->deref()) {
|
||||
delete d;
|
||||
}
|
||||
delete d;
|
||||
}
|
||||
|
||||
MP4::CoverArt::Format
|
||||
MP4::CoverArt::format() const {
|
||||
return d->format;
|
||||
return d->data->format;
|
||||
}
|
||||
|
||||
ByteVector
|
||||
MP4::CoverArt::data() const {
|
||||
return d->data;
|
||||
return d->data->data;
|
||||
}
|
||||
|
2
3rdparty/taglib/mp4/mp4coverart.h
vendored
2
3rdparty/taglib/mp4/mp4coverart.h
vendored
@ -51,7 +51,7 @@ class TAGLIB_EXPORT CoverArt {
|
||||
explicit CoverArt(Format format, const ByteVector &data);
|
||||
~CoverArt();
|
||||
|
||||
explicit CoverArt(const CoverArt &item);
|
||||
CoverArt(const CoverArt &item);
|
||||
|
||||
/*!
|
||||
* Copies the contents of \a item into this CoverArt.
|
||||
|
22
3rdparty/taglib/mp4/mp4file.cpp
vendored
22
3rdparty/taglib/mp4/mp4file.cpp
vendored
@ -23,10 +23,10 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tdebug.h>
|
||||
#include <tstring.h>
|
||||
#include <tpropertymap.h>
|
||||
#include <tagutils.h>
|
||||
#include "tdebug.h"
|
||||
#include "tstring.h"
|
||||
#include "tpropertymap.h"
|
||||
#include "tagutils.h"
|
||||
|
||||
#include "mp4atom.h"
|
||||
#include "mp4tag.h"
|
||||
@ -53,7 +53,7 @@ bool checkValid(const MP4::AtomList &list) {
|
||||
|
||||
class MP4::File::FilePrivate {
|
||||
public:
|
||||
FilePrivate() : tag(nullptr), atoms(nullptr), properties(nullptr) {}
|
||||
explicit FilePrivate() : tag(nullptr), atoms(nullptr), properties(nullptr) {}
|
||||
|
||||
~FilePrivate() {
|
||||
delete atoms;
|
||||
@ -106,18 +106,6 @@ MP4::File::tag() const {
|
||||
return d->tag;
|
||||
}
|
||||
|
||||
PropertyMap MP4::File::properties() const {
|
||||
return d->tag->properties();
|
||||
}
|
||||
|
||||
void MP4::File::removeUnsupportedProperties(const StringList &properties) {
|
||||
d->tag->removeUnsupportedProperties(properties);
|
||||
}
|
||||
|
||||
PropertyMap MP4::File::setProperties(const PropertyMap &properties) {
|
||||
return d->tag->setProperties(properties);
|
||||
}
|
||||
|
||||
MP4::AudioProperties *
|
||||
MP4::File::audioProperties() const {
|
||||
return d->properties;
|
||||
|
23
3rdparty/taglib/mp4/mp4file.h
vendored
23
3rdparty/taglib/mp4/mp4file.h
vendored
@ -70,7 +70,7 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
|
||||
/*!
|
||||
* Destroys this instance of the File.
|
||||
*/
|
||||
virtual ~File();
|
||||
~File() override;
|
||||
|
||||
/*!
|
||||
* Returns a pointer to the MP4 tag of the file.
|
||||
@ -80,34 +80,19 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
|
||||
* \note The Tag <b>is still</b> owned by the MP4::File and should not be deleted by the user.
|
||||
* It will be deleted when the file (object) is destroyed.
|
||||
*/
|
||||
Tag *tag() const;
|
||||
|
||||
/*!
|
||||
* Implements the unified property interface -- export function.
|
||||
*/
|
||||
PropertyMap properties() const;
|
||||
|
||||
/*!
|
||||
* Removes unsupported properties. Forwards to the actual Tag's removeUnsupportedProperties() function.
|
||||
*/
|
||||
void removeUnsupportedProperties(const StringList &properties);
|
||||
|
||||
/*!
|
||||
* Implements the unified property interface -- import function.
|
||||
*/
|
||||
PropertyMap setProperties(const PropertyMap &);
|
||||
Tag *tag() const override;
|
||||
|
||||
/*!
|
||||
* Returns the MP4 audio properties for this file.
|
||||
*/
|
||||
AudioProperties *audioProperties() const;
|
||||
AudioProperties *audioProperties() const override;
|
||||
|
||||
/*!
|
||||
* Save the file.
|
||||
*
|
||||
* This returns true if the save was successful.
|
||||
*/
|
||||
bool save();
|
||||
bool save() override;
|
||||
|
||||
/*!
|
||||
* Returns whether or not the file on disk actually has an MP4 tag, or the file has a Metadata Item List (ilst) atom.
|
||||
|
130
3rdparty/taglib/mp4/mp4item.cpp
vendored
130
3rdparty/taglib/mp4/mp4item.cpp
vendored
@ -23,23 +23,25 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <taglib.h>
|
||||
#include <tdebug.h>
|
||||
#include "trefcounter.h"
|
||||
#include <memory>
|
||||
|
||||
#include "taglib.h"
|
||||
#include "tdebug.h"
|
||||
#include "mp4item.h"
|
||||
#include "tutils.h"
|
||||
|
||||
using namespace Strawberry_TagLib::TagLib;
|
||||
|
||||
class MP4::Item::ItemPrivate : public RefCounter {
|
||||
public:
|
||||
ItemPrivate() : valid(true), atomDataType(TypeUndefined) {}
|
||||
namespace {
|
||||
struct ItemData {
|
||||
|
||||
bool valid;
|
||||
AtomDataType atomDataType;
|
||||
MP4::AtomDataType atomDataType;
|
||||
MP4::Item::ItemType type;
|
||||
union {
|
||||
bool m_bool;
|
||||
int m_int;
|
||||
IntPair m_intPair;
|
||||
MP4::Item::IntPair m_intPair;
|
||||
unsigned char m_byte;
|
||||
unsigned int m_uint;
|
||||
long long m_longlong;
|
||||
@ -48,14 +50,24 @@ class MP4::Item::ItemPrivate : public RefCounter {
|
||||
ByteVectorList m_byteVectorList;
|
||||
MP4::CoverArtList m_coverArtList;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
class MP4::Item::ItemPrivate {
|
||||
public:
|
||||
explicit ItemPrivate() : data(new ItemData()) {
|
||||
data->valid = true;
|
||||
data->atomDataType = MP4::TypeUndefined;
|
||||
data->type = MP4::Item::TypeUndefined;
|
||||
}
|
||||
|
||||
std::shared_ptr<ItemData> data;
|
||||
};
|
||||
|
||||
MP4::Item::Item() : d(new ItemPrivate()) {
|
||||
d->valid = false;
|
||||
d->data->valid = false;
|
||||
}
|
||||
|
||||
MP4::Item::Item(const Item &item) : d(item.d) {
|
||||
d->ref();
|
||||
}
|
||||
MP4::Item::Item(const Item &item) : d(new ItemPrivate(*item.d)) {}
|
||||
|
||||
MP4::Item &MP4::Item::operator=(const Item &item) {
|
||||
Item(item).swap(*this);
|
||||
@ -69,91 +81,135 @@ void MP4::Item::swap(Item &item) {
|
||||
}
|
||||
|
||||
MP4::Item::~Item() {
|
||||
if (d->deref())
|
||||
delete d;
|
||||
delete d;
|
||||
}
|
||||
|
||||
MP4::Item::Item(bool value) : d(new ItemPrivate()) {
|
||||
d->m_bool = value;
|
||||
d->data->m_bool = value;
|
||||
d->data->type = TypeBool;
|
||||
}
|
||||
|
||||
MP4::Item::Item(int value) : d(new ItemPrivate()) {
|
||||
d->m_int = value;
|
||||
d->data->m_int = value;
|
||||
d->data->type = TypeInt;
|
||||
}
|
||||
|
||||
MP4::Item::Item(unsigned char value) : d(new ItemPrivate()) {
|
||||
d->m_byte = value;
|
||||
d->data->m_byte = value;
|
||||
d->data->type = TypeByte;
|
||||
}
|
||||
|
||||
MP4::Item::Item(unsigned int value) : d(new ItemPrivate()) {
|
||||
d->m_uint = value;
|
||||
d->data->m_uint = value;
|
||||
d->data->type = TypeUInt;
|
||||
}
|
||||
|
||||
MP4::Item::Item(long long value) : d(new ItemPrivate()) {
|
||||
d->m_longlong = value;
|
||||
d->data->m_longlong = value;
|
||||
d->data->type = TypeLongLong;
|
||||
}
|
||||
|
||||
MP4::Item::Item(int first, int second) : d(new ItemPrivate()) {
|
||||
d->m_intPair.first = first;
|
||||
d->m_intPair.second = second;
|
||||
MP4::Item::Item(int value1, int value2) : d(new ItemPrivate()) {
|
||||
d->data->m_intPair.first = value1;
|
||||
d->data->m_intPair.second = value2;
|
||||
d->data->type = TypeIntPair;
|
||||
}
|
||||
|
||||
MP4::Item::Item(const ByteVectorList &value) : d(new ItemPrivate()) {
|
||||
d->m_byteVectorList = value;
|
||||
d->data->m_byteVectorList = value;
|
||||
d->data->type = TypeByteVectorList;
|
||||
}
|
||||
|
||||
MP4::Item::Item(const StringList &value) : d(new ItemPrivate()) {
|
||||
d->m_stringList = value;
|
||||
d->data->m_stringList = value;
|
||||
d->data->type = TypeStringList;
|
||||
}
|
||||
|
||||
MP4::Item::Item(const MP4::CoverArtList &value) : d(new ItemPrivate()) {
|
||||
d->m_coverArtList = value;
|
||||
d->data->m_coverArtList = value;
|
||||
d->data->type = TypeCoverArtList;
|
||||
}
|
||||
|
||||
void MP4::Item::setAtomDataType(MP4::AtomDataType type) {
|
||||
d->atomDataType = type;
|
||||
d->data->atomDataType = type;
|
||||
}
|
||||
|
||||
MP4::AtomDataType MP4::Item::atomDataType() const {
|
||||
return d->atomDataType;
|
||||
return d->data->atomDataType;
|
||||
}
|
||||
|
||||
bool MP4::Item::toBool() const {
|
||||
return d->m_bool;
|
||||
return d->data->m_bool;
|
||||
}
|
||||
|
||||
int MP4::Item::toInt() const {
|
||||
return d->m_int;
|
||||
return d->data->m_int;
|
||||
}
|
||||
|
||||
unsigned char MP4::Item::toByte() const {
|
||||
return d->m_byte;
|
||||
return d->data->m_byte;
|
||||
}
|
||||
|
||||
unsigned int MP4::Item::toUInt() const {
|
||||
return d->m_uint;
|
||||
return d->data->m_uint;
|
||||
}
|
||||
|
||||
long long MP4::Item::toLongLong() const {
|
||||
return d->m_longlong;
|
||||
return d->data->m_longlong;
|
||||
}
|
||||
|
||||
MP4::Item::IntPair MP4::Item::toIntPair() const {
|
||||
return d->m_intPair;
|
||||
return d->data->m_intPair;
|
||||
}
|
||||
|
||||
StringList MP4::Item::toStringList() const {
|
||||
return d->m_stringList;
|
||||
return d->data->m_stringList;
|
||||
}
|
||||
|
||||
ByteVectorList MP4::Item::toByteVectorList() const {
|
||||
return d->m_byteVectorList;
|
||||
return d->data->m_byteVectorList;
|
||||
}
|
||||
|
||||
MP4::CoverArtList MP4::Item::toCoverArtList() const {
|
||||
return d->m_coverArtList;
|
||||
return d->data->m_coverArtList;
|
||||
}
|
||||
|
||||
bool MP4::Item::isValid() const {
|
||||
return d->valid;
|
||||
return d->data->valid;
|
||||
}
|
||||
|
||||
String MP4::Item::toString() const {
|
||||
|
||||
StringList desc;
|
||||
switch (d->data->type) {
|
||||
case TypeBool:
|
||||
return d->data->m_bool ? "true" : "false";
|
||||
case TypeInt:
|
||||
return Utils::formatString("%d", d->data->m_int);
|
||||
case TypeIntPair:
|
||||
return Utils::formatString("%d/%d", d->data->m_intPair.first, d->data->m_intPair.second);
|
||||
case TypeByte:
|
||||
return Utils::formatString("%d", d->data->m_byte);
|
||||
case TypeUInt:
|
||||
return Utils::formatString("%u", d->data->m_uint);
|
||||
case TypeLongLong:
|
||||
return Utils::formatString("%lld", d->data->m_longlong);
|
||||
case TypeStringList:
|
||||
return d->data->m_stringList.toString(" / ");
|
||||
case TypeByteVectorList:
|
||||
for (size_t i = 0; i < d->data->m_byteVectorList.size(); i++) {
|
||||
desc.append(Utils::formatString(
|
||||
"[%d bytes of data]", static_cast<int>(d->data->m_byteVectorList[i].size())));
|
||||
}
|
||||
return desc.toString(", ");
|
||||
case TypeCoverArtList:
|
||||
for (size_t i = 0; i < d->data->m_coverArtList.size(); i++) {
|
||||
desc.append(Utils::formatString("[%d bytes of data]", static_cast<int>(d->data->m_coverArtList[i].data().size())));
|
||||
}
|
||||
return desc.toString(", ");
|
||||
case TypeUndefined:
|
||||
return "[unknown]";
|
||||
}
|
||||
return String();
|
||||
|
||||
}
|
||||
|
17
3rdparty/taglib/mp4/mp4item.h
vendored
17
3rdparty/taglib/mp4/mp4item.h
vendored
@ -40,6 +40,19 @@ class TAGLIB_EXPORT Item {
|
||||
int first, second;
|
||||
};
|
||||
|
||||
enum ItemType {
|
||||
TypeUndefined = 0,
|
||||
TypeBool,
|
||||
TypeInt,
|
||||
TypeIntPair,
|
||||
TypeByte,
|
||||
TypeUInt,
|
||||
TypeLongLong,
|
||||
TypeStringList,
|
||||
TypeByteVectorList,
|
||||
TypeCoverArtList,
|
||||
};
|
||||
|
||||
explicit Item();
|
||||
Item(const Item &item);
|
||||
|
||||
@ -78,8 +91,12 @@ class TAGLIB_EXPORT Item {
|
||||
ByteVectorList toByteVectorList() const;
|
||||
CoverArtList toCoverArtList() const;
|
||||
|
||||
ItemType type() const;
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
String toString() const;
|
||||
|
||||
private:
|
||||
class ItemPrivate;
|
||||
ItemPrivate *d;
|
||||
|
60
3rdparty/taglib/mp4/mp4properties.cpp
vendored
60
3rdparty/taglib/mp4/mp4properties.cpp
vendored
@ -23,8 +23,8 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tdebug.h>
|
||||
#include <tstring.h>
|
||||
#include "tdebug.h"
|
||||
#include "tstring.h"
|
||||
#include "mp4file.h"
|
||||
#include "mp4atom.h"
|
||||
#include "mp4properties.h"
|
||||
@ -33,13 +33,13 @@ using namespace Strawberry_TagLib::TagLib;
|
||||
|
||||
class MP4::AudioProperties::AudioPropertiesPrivate {
|
||||
public:
|
||||
AudioPropertiesPrivate() : length(0),
|
||||
bitrate(0),
|
||||
sampleRate(0),
|
||||
channels(0),
|
||||
bitsPerSample(0),
|
||||
encrypted(false),
|
||||
codec(MP4::AudioProperties::Unknown) {}
|
||||
explicit AudioPropertiesPrivate() : length(0),
|
||||
bitrate(0),
|
||||
sampleRate(0),
|
||||
channels(0),
|
||||
bitsPerSample(0),
|
||||
encrypted(false),
|
||||
codec(MP4::AudioProperties::Unknown) {}
|
||||
|
||||
int length;
|
||||
int bitrate;
|
||||
@ -54,7 +54,7 @@ class MP4::AudioProperties::AudioPropertiesPrivate {
|
||||
// public members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
MP4::AudioProperties::AudioProperties(File *file, MP4::Atoms *atoms, ReadStyle style) : Strawberry_TagLib::TagLib::AudioProperties(style), d(new AudioPropertiesPrivate()) {
|
||||
MP4::AudioProperties::AudioProperties(File *file, MP4::Atoms *atoms, ReadStyle) : Strawberry_TagLib::TagLib::AudioProperties(), d(new AudioPropertiesPrivate()) {
|
||||
read(file, atoms);
|
||||
}
|
||||
|
||||
@ -95,6 +95,26 @@ MP4::AudioProperties::codec() const {
|
||||
return d->codec;
|
||||
}
|
||||
|
||||
String MP4::AudioProperties::toString() const {
|
||||
|
||||
String format;
|
||||
if (d->codec == AAC) {
|
||||
format = "AAC";
|
||||
}
|
||||
else if (d->codec == ALAC) {
|
||||
format = "ALAC";
|
||||
}
|
||||
else {
|
||||
format = "Unknown";
|
||||
}
|
||||
StringList desc;
|
||||
desc.append("MPEG-4 audio (" + format + ")");
|
||||
desc.append(String::number(lengthInSeconds()) + " seconds");
|
||||
desc.append(String::number(bitrate()) + " kbps");
|
||||
return desc.toString(", ");
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// private members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -147,16 +167,16 @@ void MP4::AudioProperties::read(File *file, Atoms *atoms) {
|
||||
debug("MP4: Atom 'trak.mdia.mdhd' is smaller than expected");
|
||||
return;
|
||||
}
|
||||
unit = data.toUInt(28U);
|
||||
length = data.toLongLong(32U);
|
||||
unit = data.toUInt32BE(28);
|
||||
length = data.toInt64BE(32);
|
||||
}
|
||||
else {
|
||||
if (data.size() < 24 + 8) {
|
||||
debug("MP4: Atom 'trak.mdia.mdhd' is smaller than expected");
|
||||
return;
|
||||
}
|
||||
unit = data.toUInt(20U);
|
||||
length = data.toUInt(24U);
|
||||
unit = data.toUInt32BE(20);
|
||||
length = data.toUInt32BE(24);
|
||||
}
|
||||
if (unit > 0 && length > 0)
|
||||
d->length = static_cast<int>(length * 1000.0 / unit + 0.5);
|
||||
@ -170,9 +190,9 @@ void MP4::AudioProperties::read(File *file, Atoms *atoms) {
|
||||
data = file->readBlock(atom->length);
|
||||
if (data.containsAt("mp4a", 20)) {
|
||||
d->codec = AAC;
|
||||
d->channels = data.toShort(40U);
|
||||
d->bitsPerSample = data.toShort(42U);
|
||||
d->sampleRate = data.toUInt(46U);
|
||||
d->channels = data.toUInt16BE(40);
|
||||
d->bitsPerSample = data.toUInt16BE(42);
|
||||
d->sampleRate = data.toUInt32BE(46);
|
||||
if (data.containsAt("esds", 56) && data[64] == 0x03) {
|
||||
unsigned int pos = 65;
|
||||
if (data.containsAt("\x80\x80\x80", pos)) {
|
||||
@ -185,7 +205,7 @@ void MP4::AudioProperties::read(File *file, Atoms *atoms) {
|
||||
pos += 3;
|
||||
}
|
||||
pos += 10;
|
||||
d->bitrate = static_cast<int>((data.toUInt(pos) + 500) / 1000.0 + 0.5);
|
||||
d->bitrate = static_cast<int>((data.toUInt32BE(pos) + 500) / 1000.0 + 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -194,8 +214,8 @@ void MP4::AudioProperties::read(File *file, Atoms *atoms) {
|
||||
d->codec = ALAC;
|
||||
d->bitsPerSample = data.at(69);
|
||||
d->channels = data.at(73);
|
||||
d->bitrate = static_cast<int>(data.toUInt(80U) / 1000.0 + 0.5);
|
||||
d->sampleRate = data.toUInt(84U);
|
||||
d->bitrate = static_cast<int>(data.toUInt32BE(80) / 1000.0 + 0.5);
|
||||
d->sampleRate = data.toUInt32BE(84);
|
||||
}
|
||||
}
|
||||
|
||||
|
14
3rdparty/taglib/mp4/mp4properties.h
vendored
14
3rdparty/taglib/mp4/mp4properties.h
vendored
@ -46,36 +46,36 @@ class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioPro
|
||||
};
|
||||
|
||||
explicit AudioProperties(File *file, Atoms *atoms, ReadStyle style = Average);
|
||||
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.
|
||||
@ -92,6 +92,8 @@ class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioPro
|
||||
*/
|
||||
Codec codec() const;
|
||||
|
||||
String toString() const override;
|
||||
|
||||
private:
|
||||
void read(File *file, Atoms *atoms);
|
||||
|
||||
|
176
3rdparty/taglib/mp4/mp4tag.cpp
vendored
176
3rdparty/taglib/mp4/mp4tag.cpp
vendored
@ -23,9 +23,10 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tdebug.h>
|
||||
#include <tstring.h>
|
||||
#include <tpropertymap.h>
|
||||
#include "tdebug.h"
|
||||
#include "tstring.h"
|
||||
#include "tpicturemap.h"
|
||||
#include "tpropertymap.h"
|
||||
#include "mp4atom.h"
|
||||
#include "mp4tag.h"
|
||||
#include "id3v1genres.h"
|
||||
@ -34,7 +35,7 @@ using namespace Strawberry_TagLib::TagLib;
|
||||
|
||||
class MP4::Tag::TagPrivate {
|
||||
public:
|
||||
TagPrivate() : file(nullptr), atoms(nullptr) {}
|
||||
explicit TagPrivate() : file(nullptr), atoms(nullptr) {}
|
||||
|
||||
Strawberry_TagLib::TagLib::File *file;
|
||||
Atoms *atoms;
|
||||
@ -78,7 +79,7 @@ MP4::Tag::Tag(Strawberry_TagLib::TagLib::File *file, MP4::Atoms *atoms) : d(new
|
||||
addItem(atom->name, StringList(String(val.data, String::UTF8)));
|
||||
}
|
||||
else {
|
||||
addItem(atom->name, static_cast<int>((val.data.toShort())));
|
||||
addItem(atom->name, static_cast<int>((val.data.toUInt16LE(0))));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -117,16 +118,16 @@ MP4::AtomDataList MP4::Tag::parseData2(const MP4::Atom *atom, int expectedFlags,
|
||||
AtomDataList result;
|
||||
ByteVector data = d->file->readBlock(atom->length - 8);
|
||||
int i = 0;
|
||||
unsigned int pos = 0;
|
||||
size_t pos = 0;
|
||||
while (pos < data.size()) {
|
||||
const int length = static_cast<int>(data.toUInt(pos));
|
||||
const int length = static_cast<int>(data.toUInt32BE(pos));
|
||||
if (length < 12) {
|
||||
debug("MP4: Too short atom");
|
||||
return result;
|
||||
}
|
||||
|
||||
const ByteVector name = data.mid(pos + 4, 4);
|
||||
const int flags = static_cast<int>(data.toUInt(pos + 8));
|
||||
const int flags = static_cast<int>(data.toUInt32BE(pos + 8));
|
||||
if (freeForm && i < 2) {
|
||||
if (i == 0 && name != "mean") {
|
||||
debug("MP4: Unexpected atom \"" + name + "\", expecting \"mean\"");
|
||||
@ -169,7 +170,7 @@ void MP4::Tag::parseInt(const MP4::Atom *atom) {
|
||||
|
||||
ByteVectorList data = parseData(atom);
|
||||
if (!data.isEmpty()) {
|
||||
addItem(atom->name, static_cast<int>(data[0].toShort()));
|
||||
addItem(atom->name, (int)data[0].toInt16BE(0));
|
||||
}
|
||||
|
||||
}
|
||||
@ -178,7 +179,7 @@ void MP4::Tag::parseUInt(const MP4::Atom *atom) {
|
||||
|
||||
ByteVectorList data = parseData(atom);
|
||||
if (!data.isEmpty()) {
|
||||
addItem(atom->name, data[0].toUInt());
|
||||
addItem(atom->name, data[0].toUInt32BE(0));
|
||||
}
|
||||
|
||||
}
|
||||
@ -187,7 +188,7 @@ void MP4::Tag::parseLongLong(const MP4::Atom *atom) {
|
||||
|
||||
ByteVectorList data = parseData(atom);
|
||||
if (!data.isEmpty()) {
|
||||
addItem(atom->name, data[0].toLongLong());
|
||||
addItem(atom->name, data[0].toInt64BE(0));
|
||||
}
|
||||
|
||||
}
|
||||
@ -205,7 +206,7 @@ void MP4::Tag::parseGnre(const MP4::Atom *atom) {
|
||||
|
||||
ByteVectorList data = parseData(atom);
|
||||
if (!data.isEmpty()) {
|
||||
int idx = static_cast<int>(data[0].toShort());
|
||||
int idx = static_cast<int>(data[0].toInt16BE(0));
|
||||
if (idx > 0) {
|
||||
addItem("\251gen", StringList(ID3v1::genre(idx - 1)));
|
||||
}
|
||||
@ -217,8 +218,8 @@ void MP4::Tag::parseIntPair(const MP4::Atom *atom) {
|
||||
|
||||
ByteVectorList data = parseData(atom);
|
||||
if (!data.isEmpty()) {
|
||||
const int a = data[0].toShort(2U);
|
||||
const int b = data[0].toShort(4U);
|
||||
const int a = data[0].toInt16BE(2);
|
||||
const int b = data[0].toInt16BE(4);
|
||||
addItem(atom->name, MP4::Item(a, b));
|
||||
}
|
||||
|
||||
@ -294,7 +295,7 @@ void MP4::Tag::parseCovr(const MP4::Atom *atom) {
|
||||
ByteVector data = d->file->readBlock(atom->length - 8);
|
||||
unsigned int pos = 0;
|
||||
while (pos < data.size()) {
|
||||
const int length = static_cast<int>(data.toUInt(pos));
|
||||
const int length = static_cast<int>(data.toUInt32BE(pos));
|
||||
if (length < 12) {
|
||||
debug("MP4: Too short atom");
|
||||
break;
|
||||
@ -302,7 +303,7 @@ void MP4::Tag::parseCovr(const MP4::Atom *atom) {
|
||||
}
|
||||
|
||||
const ByteVector name = data.mid(pos + 4, 4);
|
||||
const int flags = static_cast<int>(data.toUInt(pos + 8));
|
||||
const int flags = static_cast<int>(data.toUInt32BE(pos + 8));
|
||||
if (name != "data") {
|
||||
debug("MP4: Unexpected atom \"" + name + "\", expecting \"data\"");
|
||||
break;
|
||||
@ -332,14 +333,14 @@ ByteVector MP4::Tag::padIlst(const ByteVector &data, int length) const {
|
||||
}
|
||||
|
||||
ByteVector MP4::Tag::renderAtom(const ByteVector &name, const ByteVector &data) const {
|
||||
return ByteVector::fromUInt(data.size() + 8) + name + data;
|
||||
return ByteVector::fromUInt32BE(data.size() + 8) + name + data;
|
||||
}
|
||||
|
||||
ByteVector MP4::Tag::renderData(const ByteVector &name, int flags, const ByteVectorList &data) const {
|
||||
|
||||
ByteVector result;
|
||||
for (ByteVectorList::ConstIterator it = data.begin(); it != data.end(); ++it) {
|
||||
result.append(renderAtom("data", ByteVector::fromUInt(flags) + ByteVector(4, '\0') + *it));
|
||||
result.append(renderAtom("data", ByteVector::fromUInt32BE(flags) + ByteVector(4, '\0') + *it));
|
||||
}
|
||||
return renderAtom(name, result);
|
||||
|
||||
@ -356,7 +357,7 @@ ByteVector MP4::Tag::renderBool(const ByteVector &name, const MP4::Item &item) c
|
||||
ByteVector MP4::Tag::renderInt(const ByteVector &name, const MP4::Item &item) const {
|
||||
|
||||
ByteVectorList data;
|
||||
data.append(ByteVector::fromShort(item.toInt()));
|
||||
data.append(ByteVector::fromUInt16BE(item.toInt()));
|
||||
return renderData(name, TypeInteger, data);
|
||||
|
||||
}
|
||||
@ -364,7 +365,7 @@ ByteVector MP4::Tag::renderInt(const ByteVector &name, const MP4::Item &item) co
|
||||
ByteVector MP4::Tag::renderUInt(const ByteVector &name, const MP4::Item &item) const {
|
||||
|
||||
ByteVectorList data;
|
||||
data.append(ByteVector::fromUInt(item.toUInt()));
|
||||
data.append(ByteVector::fromUInt32BE(item.toUInt()));
|
||||
return renderData(name, TypeInteger, data);
|
||||
|
||||
}
|
||||
@ -372,7 +373,7 @@ ByteVector MP4::Tag::renderUInt(const ByteVector &name, const MP4::Item &item) c
|
||||
ByteVector MP4::Tag::renderLongLong(const ByteVector &name, const MP4::Item &item) const {
|
||||
|
||||
ByteVectorList data;
|
||||
data.append(ByteVector::fromLongLong(item.toLongLong()));
|
||||
data.append(ByteVector::fromUInt64BE(item.toLongLong()));
|
||||
return renderData(name, TypeInteger, data);
|
||||
|
||||
}
|
||||
@ -389,8 +390,8 @@ ByteVector MP4::Tag::renderIntPair(const ByteVector &name, const MP4::Item &item
|
||||
|
||||
ByteVectorList data;
|
||||
data.append(ByteVector(2, '\0') +
|
||||
ByteVector::fromShort(item.toIntPair().first) +
|
||||
ByteVector::fromShort(item.toIntPair().second) +
|
||||
ByteVector::fromUInt16BE(item.toIntPair().first) +
|
||||
ByteVector::fromUInt16BE(item.toIntPair().second) +
|
||||
ByteVector(2, '\0'));
|
||||
return renderData(name, TypeImplicit, data);
|
||||
|
||||
@ -400,8 +401,8 @@ ByteVector MP4::Tag::renderIntPairNoTrailing(const ByteVector &name, const MP4::
|
||||
|
||||
ByteVectorList data;
|
||||
data.append(ByteVector(2, '\0') +
|
||||
ByteVector::fromShort(item.toIntPair().first) +
|
||||
ByteVector::fromShort(item.toIntPair().second));
|
||||
ByteVector::fromUInt16BE(item.toIntPair().first) +
|
||||
ByteVector::fromUInt16BE(item.toIntPair().second));
|
||||
return renderData(name, TypeImplicit, data);
|
||||
|
||||
}
|
||||
@ -422,7 +423,7 @@ ByteVector MP4::Tag::renderCovr(const ByteVector &name, const MP4::Item &item) c
|
||||
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()));
|
||||
data.append(renderAtom("data", ByteVector::fromUInt32BE(it->format()) + ByteVector(4, '\0') + it->data()));
|
||||
}
|
||||
return renderAtom(name, data);
|
||||
|
||||
@ -436,8 +437,8 @@ ByteVector MP4::Tag::renderFreeForm(const String &name, const MP4::Item &item) c
|
||||
return ByteVector();
|
||||
}
|
||||
ByteVector data;
|
||||
data.append(renderAtom("mean", ByteVector::fromUInt(0) + header[1].data(String::UTF8)));
|
||||
data.append(renderAtom("name", ByteVector::fromUInt(0) + header[2].data(String::UTF8)));
|
||||
data.append(renderAtom("mean", ByteVector::fromUInt32BE(0) + header[1].data(String::UTF8)));
|
||||
data.append(renderAtom("name", ByteVector::fromUInt32BE(0) + header[2].data(String::UTF8)));
|
||||
AtomDataType type = item.atomDataType();
|
||||
if (type == TypeUndefined) {
|
||||
if (!item.toStringList().isEmpty()) {
|
||||
@ -450,13 +451,13 @@ ByteVector MP4::Tag::renderFreeForm(const String &name, const MP4::Item &item) c
|
||||
if (type == TypeUTF8) {
|
||||
StringList value = item.toStringList();
|
||||
for (StringList::ConstIterator it = value.begin(); it != value.end(); ++it) {
|
||||
data.append(renderAtom("data", ByteVector::fromUInt(type) + ByteVector(4, '\0') + it->data(String::UTF8)));
|
||||
data.append(renderAtom("data", ByteVector::fromUInt32BE(type) + ByteVector(4, '\0') + it->data(String::UTF8)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
ByteVectorList value = item.toByteVectorList();
|
||||
for (ByteVectorList::ConstIterator it = value.begin(); it != value.end(); ++it) {
|
||||
data.append(renderAtom("data", ByteVector::fromUInt(type) + ByteVector(4, '\0') + *it));
|
||||
data.append(renderAtom("data", ByteVector::fromUInt32BE(type) + ByteVector(4, '\0') + *it));
|
||||
}
|
||||
}
|
||||
return renderAtom("----", data);
|
||||
@ -542,24 +543,24 @@ void MP4::Tag::updateParents(const AtomList &path, long delta, int ignore) {
|
||||
|
||||
for (AtomList::ConstIterator it = path.begin(); it != itEnd; ++it) {
|
||||
d->file->seek((*it)->offset);
|
||||
long size = d->file->readBlock(4).toUInt();
|
||||
long size = d->file->readBlock(4).toUInt32BE(0);
|
||||
// 64-bit
|
||||
if (size == 1) {
|
||||
d->file->seek(4, File::Current); // Skip name
|
||||
long long longSize = d->file->readBlock(8).toLongLong();
|
||||
long long longSize = d->file->readBlock(8).toInt64BE(0);
|
||||
// Seek the offset of the 64-bit size
|
||||
d->file->seek((*it)->offset + 8);
|
||||
d->file->writeBlock(ByteVector::fromLongLong(longSize + delta));
|
||||
d->file->writeBlock(ByteVector::fromUInt64BE(longSize + delta));
|
||||
}
|
||||
// 32-bit
|
||||
else {
|
||||
d->file->seek((*it)->offset);
|
||||
d->file->writeBlock(ByteVector::fromUInt(size + delta));
|
||||
d->file->writeBlock(ByteVector::fromUInt32BE(size + delta));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MP4::Tag::updateOffsets(long delta, long offset) {
|
||||
void MP4::Tag::updateOffsets(long delta, long long offset) {
|
||||
|
||||
MP4::Atom *moov = d->atoms->find("moov");
|
||||
if (moov) {
|
||||
@ -571,15 +572,15 @@ void MP4::Tag::updateOffsets(long delta, long offset) {
|
||||
}
|
||||
d->file->seek(atom->offset + 12);
|
||||
ByteVector data = d->file->readBlock(atom->length - 12);
|
||||
unsigned int count = data.toUInt();
|
||||
unsigned int count = data.toUInt32BE(0);
|
||||
d->file->seek(atom->offset + 16);
|
||||
unsigned int pos = 4;
|
||||
size_t pos = 4;
|
||||
while (count--) {
|
||||
long o = static_cast<long>(data.toUInt(pos));
|
||||
long o = data.toUInt32BE(pos);
|
||||
if (o > offset) {
|
||||
o += delta;
|
||||
}
|
||||
d->file->writeBlock(ByteVector::fromUInt(o));
|
||||
d->file->writeBlock(ByteVector::fromUInt32BE(o));
|
||||
pos += 4;
|
||||
}
|
||||
}
|
||||
@ -592,15 +593,15 @@ void MP4::Tag::updateOffsets(long delta, long offset) {
|
||||
}
|
||||
d->file->seek(atom->offset + 12);
|
||||
ByteVector data = d->file->readBlock(atom->length - 12);
|
||||
unsigned int count = data.toUInt();
|
||||
unsigned int count = data.toUInt32BE(0);
|
||||
d->file->seek(atom->offset + 16);
|
||||
unsigned int pos = 4;
|
||||
size_t pos = 4;
|
||||
while (count--) {
|
||||
long long o = data.toLongLong(pos);
|
||||
long long o = data.toInt64BE(pos);
|
||||
if (o > offset) {
|
||||
o += delta;
|
||||
}
|
||||
d->file->writeBlock(ByteVector::fromLongLong(o));
|
||||
d->file->writeBlock(ByteVector::fromUInt64BE(o));
|
||||
pos += 8;
|
||||
}
|
||||
}
|
||||
@ -616,14 +617,14 @@ void MP4::Tag::updateOffsets(long delta, long offset) {
|
||||
}
|
||||
d->file->seek(atom->offset + 9);
|
||||
ByteVector data = d->file->readBlock(atom->length - 9);
|
||||
const unsigned int flags = data.toUInt(0, 3, true);
|
||||
const unsigned int flags = data.toUInt24BE(0);
|
||||
if (flags & 1) {
|
||||
long long o = data.toLongLong(7U);
|
||||
long long o = data.toInt64BE(7);
|
||||
if (o > offset) {
|
||||
o += delta;
|
||||
}
|
||||
d->file->seek(atom->offset + 16);
|
||||
d->file->writeBlock(ByteVector::fromLongLong(o));
|
||||
d->file->writeBlock(ByteVector::fromUInt64BE(o));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -640,7 +641,7 @@ void MP4::Tag::saveNew(ByteVector data) {
|
||||
data = renderAtom("udta", data);
|
||||
}
|
||||
|
||||
long offset = path.back()->offset + 8;
|
||||
long long offset = path.back()->offset + 8;
|
||||
d->file->insert(data, offset, 0);
|
||||
|
||||
updateParents(path, data.size());
|
||||
@ -658,8 +659,8 @@ void MP4::Tag::saveExisting(ByteVector data, const AtomList &path) {
|
||||
AtomList::ConstIterator it = path.end();
|
||||
|
||||
MP4::Atom *ilst = *(--it);
|
||||
long offset = ilst->offset;
|
||||
long length = ilst->length;
|
||||
long long offset = ilst->offset;
|
||||
long long length = ilst->length;
|
||||
|
||||
MP4::Atom *meta = *(--it);
|
||||
AtomList::ConstIterator index = meta->children.find(ilst);
|
||||
@ -690,7 +691,7 @@ void MP4::Tag::saveExisting(ByteVector data, const AtomList &path) {
|
||||
delta = data.size() - length;
|
||||
}
|
||||
else if (delta < 0) {
|
||||
data.append(padIlst(data, -delta - 8));
|
||||
data.append(padIlst(data, 0 - delta - 8));
|
||||
delta = 0;
|
||||
}
|
||||
|
||||
@ -745,6 +746,42 @@ unsigned int MP4::Tag::track() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
PictureMap MP4::Tag::pictures() const {
|
||||
|
||||
if (!d->items.contains("covr"))
|
||||
return PictureMap();
|
||||
|
||||
CoverArtList list = d->items["covr"].toCoverArtList();
|
||||
if (list.isEmpty())
|
||||
return PictureMap();
|
||||
|
||||
PictureMap map;
|
||||
for (CoverArtList::ConstIterator it = list.begin(); it != list.end(); ++it) {
|
||||
CoverArt art = *it;
|
||||
String mime = "image/";
|
||||
switch (art.format()) {
|
||||
case CoverArt::BMP:
|
||||
mime.append("bmp");
|
||||
break;
|
||||
case CoverArt::JPEG:
|
||||
mime.append("jpeg");
|
||||
break;
|
||||
case CoverArt::GIF:
|
||||
mime.append("gif");
|
||||
break;
|
||||
case CoverArt::PNG:
|
||||
mime.append("png");
|
||||
break;
|
||||
case CoverArt::Unknown:
|
||||
break;
|
||||
}
|
||||
Picture picture(art.data(), Picture::Other, mime);
|
||||
map.insert(picture);
|
||||
}
|
||||
return PictureMap(map);
|
||||
|
||||
}
|
||||
|
||||
void MP4::Tag::setTitle(const String &value) {
|
||||
d->items["\251nam"] = StringList(value);
|
||||
}
|
||||
@ -787,6 +824,35 @@ void MP4::Tag::setTrack(unsigned int value) {
|
||||
|
||||
}
|
||||
|
||||
void MP4::Tag::setPictures(const PictureMap &l) {
|
||||
|
||||
CoverArtList list;
|
||||
for (PictureMap::ConstIterator pictureMapIt = l.begin(); pictureMapIt != l.end(); ++pictureMapIt) {
|
||||
PictureList pictures = pictureMapIt->second;
|
||||
for (PictureList::ConstIterator pictureListIt = pictures.begin(); pictureListIt != pictures.end(); ++pictureListIt) {
|
||||
Picture picture = *pictureListIt;
|
||||
CoverArt::Format format;
|
||||
String mime = picture.mime();
|
||||
if (String("image/") == mime)
|
||||
format = CoverArt::Unknown;
|
||||
else if (String("image/bmp") == mime)
|
||||
format = CoverArt::BMP;
|
||||
else if (String("image/png") == mime)
|
||||
format = CoverArt::PNG;
|
||||
else if (String("image/gif") == mime)
|
||||
format = CoverArt::GIF;
|
||||
else if (String("image/jpeg") == mime)
|
||||
format = CoverArt::JPEG;
|
||||
else
|
||||
format = CoverArt::Unknown;
|
||||
CoverArt art(format, picture.data());
|
||||
list.append(art);
|
||||
}
|
||||
}
|
||||
d->items["covr"] = list;
|
||||
|
||||
}
|
||||
|
||||
bool MP4::Tag::isEmpty() const {
|
||||
return d->items.isEmpty();
|
||||
}
|
||||
@ -811,6 +877,16 @@ bool MP4::Tag::contains(const String &key) const {
|
||||
return d->items.contains(key);
|
||||
}
|
||||
|
||||
String MP4::Tag::toString() const {
|
||||
|
||||
StringList desc;
|
||||
for (MP4::ItemListMap::Iterator i = d->items.begin(); i != d->items.end(); i++) {
|
||||
desc.append(i->first + "=" + i->second.toString());
|
||||
}
|
||||
return desc.toString("\n");
|
||||
|
||||
}
|
||||
|
||||
namespace {
|
||||
const char *keyTranslation[][2] = {
|
||||
{ "\251nam", "TITLE" },
|
||||
|
45
3rdparty/taglib/mp4/mp4tag.h
vendored
45
3rdparty/taglib/mp4/mp4tag.h
vendored
@ -40,31 +40,34 @@ namespace TagLib {
|
||||
namespace MP4 {
|
||||
|
||||
typedef Strawberry_TagLib::TagLib::Map<String, Item> ItemMap;
|
||||
typedef Strawberry_TagLib::TagLib::Map<String, Item> ItemListMap;
|
||||
|
||||
class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||
public:
|
||||
explicit Tag();
|
||||
explicit Tag(Strawberry_TagLib::TagLib::File *file, Atoms *atoms);
|
||||
virtual ~Tag();
|
||||
~Tag() override;
|
||||
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;
|
||||
String title() const override;
|
||||
String artist() const override;
|
||||
String album() const override;
|
||||
String comment() const override;
|
||||
String genre() const override;
|
||||
unsigned int year() const override;
|
||||
unsigned int track() const override;
|
||||
PictureMap pictures() const override;
|
||||
|
||||
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);
|
||||
void setTitle(const String &value) override;
|
||||
void setArtist(const String &value) override;
|
||||
void setAlbum(const String &value) override;
|
||||
void setComment(const String &value) override;
|
||||
void setGenre(const String &value) override;
|
||||
void setYear(unsigned int value) override;
|
||||
void setTrack(unsigned int value) override;
|
||||
void setPictures(const PictureMap &l) override;
|
||||
|
||||
virtual bool isEmpty() const;
|
||||
bool isEmpty() const override;
|
||||
/*!
|
||||
* Returns a string-keyed map of the MP4::Items for this tag.
|
||||
*/
|
||||
@ -90,9 +93,11 @@ class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||
*/
|
||||
bool contains(const String &key) const;
|
||||
|
||||
PropertyMap properties() const;
|
||||
void removeUnsupportedProperties(const StringList &props);
|
||||
PropertyMap setProperties(const PropertyMap &props);
|
||||
String toString() const override;
|
||||
|
||||
PropertyMap properties() const override;
|
||||
void removeUnsupportedProperties(const StringList &props) override;
|
||||
PropertyMap setProperties(const PropertyMap &props) override;
|
||||
|
||||
private:
|
||||
AtomDataList parseData2(const Atom *atom, int expectedFlags = -1, bool freeForm = false);
|
||||
@ -123,7 +128,7 @@ class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||
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 updateOffsets(long delta, long long offset);
|
||||
|
||||
void saveNew(ByteVector data);
|
||||
void saveExisting(ByteVector data, const AtomList &path);
|
||||
|
70
3rdparty/taglib/mpc/mpcfile.cpp
vendored
70
3rdparty/taglib/mpc/mpcfile.cpp
vendored
@ -23,12 +23,14 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tbytevector.h>
|
||||
#include <tstring.h>
|
||||
#include <tagunion.h>
|
||||
#include <tdebug.h>
|
||||
#include <tpropertymap.h>
|
||||
#include <tagutils.h>
|
||||
#include <memory>
|
||||
|
||||
#include "tbytevector.h"
|
||||
#include "tstring.h"
|
||||
#include "tagunion.h"
|
||||
#include "tdebug.h"
|
||||
#include "tpropertymap.h"
|
||||
#include "tagutils.h"
|
||||
|
||||
#include "mpcfile.h"
|
||||
#include "id3v1tag.h"
|
||||
@ -45,31 +47,24 @@ enum { MPCAPEIndex = 0,
|
||||
|
||||
class MPC::File::FilePrivate {
|
||||
public:
|
||||
FilePrivate() : APELocation(-1),
|
||||
APESize(0),
|
||||
ID3v1Location(-1),
|
||||
ID3v2Header(nullptr),
|
||||
ID3v2Location(-1),
|
||||
ID3v2Size(0),
|
||||
properties(nullptr) {}
|
||||
explicit FilePrivate() : APELocation(-1),
|
||||
APESize(0),
|
||||
ID3v1Location(-1),
|
||||
ID3v2Location(-1),
|
||||
ID3v2Size(0) {}
|
||||
|
||||
~FilePrivate() {
|
||||
delete ID3v2Header;
|
||||
delete properties;
|
||||
}
|
||||
long long APELocation;
|
||||
long long APESize;
|
||||
|
||||
long APELocation;
|
||||
long APESize;
|
||||
long long ID3v1Location;
|
||||
|
||||
long ID3v1Location;
|
||||
std::unique_ptr<ID3v2::Header> ID3v2Header;
|
||||
long long ID3v2Location;
|
||||
long long ID3v2Size;
|
||||
|
||||
ID3v2::Header *ID3v2Header;
|
||||
long ID3v2Location;
|
||||
long ID3v2Size;
|
||||
DoubleTagUnion tag;
|
||||
|
||||
TagUnion tag;
|
||||
|
||||
AudioProperties *properties;
|
||||
std::unique_ptr<AudioProperties> properties;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -112,14 +107,6 @@ Strawberry_TagLib::TagLib::Tag *MPC::File::tag() const {
|
||||
return &d->tag;
|
||||
}
|
||||
|
||||
PropertyMap MPC::File::properties() const {
|
||||
return d->tag.properties();
|
||||
}
|
||||
|
||||
void MPC::File::removeUnsupportedProperties(const StringList &properties) {
|
||||
d->tag.removeUnsupportedProperties(properties);
|
||||
}
|
||||
|
||||
PropertyMap MPC::File::setProperties(const PropertyMap &properties) {
|
||||
if (ID3v1Tag())
|
||||
ID3v1Tag()->setProperties(properties);
|
||||
@ -128,7 +115,7 @@ PropertyMap MPC::File::setProperties(const PropertyMap &properties) {
|
||||
}
|
||||
|
||||
MPC::AudioProperties *MPC::File::audioProperties() const {
|
||||
return d->properties;
|
||||
return d->properties.get();
|
||||
}
|
||||
|
||||
bool MPC::File::save() {
|
||||
@ -238,11 +225,8 @@ void MPC::File::strip(int tags) {
|
||||
if (!ID3v1Tag())
|
||||
APETag(true);
|
||||
|
||||
if (tags & ID3v2) {
|
||||
delete d->ID3v2Header;
|
||||
d->ID3v2Header = nullptr;
|
||||
}
|
||||
|
||||
if (tags & ID3v2)
|
||||
d->ID3v2Header.reset();
|
||||
}
|
||||
|
||||
bool MPC::File::hasID3v1Tag() const {
|
||||
@ -265,7 +249,7 @@ void MPC::File::read(bool readProperties) {
|
||||
|
||||
if (d->ID3v2Location >= 0) {
|
||||
seek(d->ID3v2Location);
|
||||
d->ID3v2Header = new ID3v2::Header(readBlock(ID3v2::Header::size()));
|
||||
d->ID3v2Header.reset(new ID3v2::Header(readBlock(ID3v2::Header::size())));
|
||||
d->ID3v2Size = d->ID3v2Header->completeTagSize();
|
||||
}
|
||||
|
||||
@ -293,7 +277,7 @@ void MPC::File::read(bool readProperties) {
|
||||
|
||||
if (readProperties) {
|
||||
|
||||
long streamLength;
|
||||
long long streamLength;
|
||||
|
||||
if (d->APELocation >= 0)
|
||||
streamLength = d->APELocation;
|
||||
@ -310,7 +294,7 @@ void MPC::File::read(bool readProperties) {
|
||||
seek(0);
|
||||
}
|
||||
|
||||
d->properties = new AudioProperties(this, streamLength);
|
||||
d->properties.reset(new AudioProperties(this, streamLength));
|
||||
}
|
||||
|
||||
}
|
||||
|
20
3rdparty/taglib/mpc/mpcfile.h
vendored
20
3rdparty/taglib/mpc/mpcfile.h
vendored
@ -104,41 +104,33 @@ 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.
|
||||
* This will be an APE tag, an ID3v1 tag or a combination of the two.
|
||||
*/
|
||||
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;
|
||||
|
||||
void removeUnsupportedProperties(const StringList &properties);
|
||||
Strawberry_TagLib::TagLib::Tag *tag() const override;
|
||||
|
||||
/*!
|
||||
* 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 &) override;
|
||||
|
||||
/*!
|
||||
* Returns the MPC::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.
|
||||
*
|
||||
* This returns true if the save was successful.
|
||||
*/
|
||||
virtual bool save();
|
||||
bool save() override;
|
||||
|
||||
/*!
|
||||
* Returns a pointer to the ID3v1 tag of the file.
|
||||
@ -205,7 +197,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);
|
||||
|
94
3rdparty/taglib/mpc/mpcproperties.cpp
vendored
94
3rdparty/taglib/mpc/mpcproperties.cpp
vendored
@ -23,29 +23,35 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tstring.h>
|
||||
#include <tdebug.h>
|
||||
|
||||
#include <bitset>
|
||||
#include <cmath>
|
||||
|
||||
#include "tstring.h"
|
||||
#include "tdebug.h"
|
||||
|
||||
#include "mpcproperties.h"
|
||||
#include "mpcfile.h"
|
||||
|
||||
using namespace Strawberry_TagLib::TagLib;
|
||||
|
||||
namespace {
|
||||
const unsigned int HeaderSize = 56;
|
||||
}
|
||||
|
||||
class MPC::AudioProperties::AudioPropertiesPrivate {
|
||||
public:
|
||||
AudioPropertiesPrivate() : version(0),
|
||||
length(0),
|
||||
bitrate(0),
|
||||
sampleRate(0),
|
||||
channels(0),
|
||||
totalFrames(0),
|
||||
sampleFrames(0),
|
||||
trackGain(0),
|
||||
trackPeak(0),
|
||||
albumGain(0),
|
||||
albumPeak(0) {}
|
||||
explicit AudioPropertiesPrivate() : 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;
|
||||
@ -54,21 +60,17 @@ class MPC::AudioProperties::AudioPropertiesPrivate {
|
||||
int channels;
|
||||
unsigned int totalFrames;
|
||||
unsigned int sampleFrames;
|
||||
int trackGain;
|
||||
int trackPeak;
|
||||
int albumGain;
|
||||
int albumPeak;
|
||||
unsigned int trackGain;
|
||||
unsigned int trackPeak;
|
||||
unsigned int albumGain;
|
||||
unsigned int albumPeak;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// public members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
MPC::AudioProperties::AudioProperties(const ByteVector &data, long streamLength, ReadStyle style) : Strawberry_TagLib::TagLib::AudioProperties(style), d(new AudioPropertiesPrivate()) {
|
||||
readSV7(data, streamLength);
|
||||
}
|
||||
|
||||
MPC::AudioProperties::AudioProperties(File *file, long streamLength, ReadStyle style) : Strawberry_TagLib::TagLib::AudioProperties(style), d(new AudioPropertiesPrivate()) {
|
||||
MPC::AudioProperties::AudioProperties(File *file, long long streamLength, ReadStyle) : Strawberry_TagLib::TagLib::AudioProperties(), d(new AudioPropertiesPrivate()) {
|
||||
|
||||
ByteVector magic = file->readBlock(4);
|
||||
if (magic == "MPCK") {
|
||||
@ -77,7 +79,7 @@ MPC::AudioProperties::AudioProperties(File *file, long streamLength, ReadStyle s
|
||||
}
|
||||
else {
|
||||
// Musepack version 7 or older, fixed size header
|
||||
readSV7(magic + file->readBlock(MPC::HeaderSize - 4), streamLength);
|
||||
readSV7(magic + file->readBlock(HeaderSize - 4), streamLength);
|
||||
}
|
||||
|
||||
}
|
||||
@ -139,7 +141,7 @@ int MPC::AudioProperties::albumPeak() const {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace {
|
||||
unsigned long readSize(File *file, unsigned int &sizeLength, bool &eof) {
|
||||
unsigned long readSize(File *file, size_t &sizeLength, bool &eof) {
|
||||
|
||||
sizeLength = 0;
|
||||
eof = false;
|
||||
@ -164,7 +166,7 @@ unsigned long readSize(File *file, unsigned int &sizeLength, bool &eof) {
|
||||
|
||||
}
|
||||
|
||||
unsigned long readSize(const ByteVector &data, unsigned int &pos) {
|
||||
unsigned long readSize(const ByteVector &data, size_t &pos) {
|
||||
|
||||
unsigned char tmp;
|
||||
unsigned long size = 0;
|
||||
@ -184,22 +186,22 @@ unsigned long readSize(const ByteVector &data, unsigned int &pos) {
|
||||
const unsigned short sftable[8] = { 44100, 48000, 37800, 32000, 0, 0, 0, 0 };
|
||||
} // namespace
|
||||
|
||||
void MPC::AudioProperties::readSV8(File *file, long streamLength) {
|
||||
void MPC::AudioProperties::readSV8(File *file, long long streamLength) {
|
||||
|
||||
bool readSH = false, readRG = false;
|
||||
|
||||
while (!readSH && !readRG) {
|
||||
const ByteVector packetType = file->readBlock(2);
|
||||
|
||||
unsigned int packetSizeLength;
|
||||
size_t packetSizeLength;
|
||||
bool eof;
|
||||
const unsigned long packetSize = readSize(file, packetSizeLength, eof);
|
||||
const size_t packetSize = readSize(file, packetSizeLength, eof);
|
||||
if (eof) {
|
||||
debug("MPC::AudioProperties::readSV8() - Reached to EOF.");
|
||||
break;
|
||||
}
|
||||
|
||||
const unsigned long dataSize = packetSize - 2 - packetSizeLength;
|
||||
const size_t dataSize = packetSize - 2 - packetSizeLength;
|
||||
|
||||
const ByteVector data = file->readBlock(dataSize);
|
||||
if (data.size() != dataSize) {
|
||||
@ -218,7 +220,7 @@ void MPC::AudioProperties::readSV8(File *file, long streamLength) {
|
||||
|
||||
readSH = true;
|
||||
|
||||
unsigned int pos = 4;
|
||||
size_t pos = 4;
|
||||
d->version = data[pos];
|
||||
pos += 1;
|
||||
d->sampleFrames = readSize(data, pos);
|
||||
@ -233,7 +235,7 @@ void MPC::AudioProperties::readSV8(File *file, long streamLength) {
|
||||
break;
|
||||
}
|
||||
|
||||
const unsigned short flags = data.toUShort(pos, true);
|
||||
const unsigned short flags = data.toUInt16BE(pos);
|
||||
pos += 2;
|
||||
|
||||
d->sampleRate = sftable[(flags >> 13) & 0x07];
|
||||
@ -259,10 +261,10 @@ void MPC::AudioProperties::readSV8(File *file, long streamLength) {
|
||||
|
||||
const int replayGainVersion = data[0];
|
||||
if (replayGainVersion == 1) {
|
||||
d->trackGain = data.toShort(1, true);
|
||||
d->trackPeak = data.toShort(3, true);
|
||||
d->albumGain = data.toShort(5, true);
|
||||
d->albumPeak = data.toShort(7, true);
|
||||
d->trackGain = data.toUInt16BE(1);
|
||||
d->trackPeak = data.toUInt16BE(3);
|
||||
d->albumGain = data.toUInt16BE(5);
|
||||
d->albumPeak = data.toUInt16BE(7);
|
||||
}
|
||||
}
|
||||
|
||||
@ -277,25 +279,25 @@ void MPC::AudioProperties::readSV8(File *file, long streamLength) {
|
||||
|
||||
}
|
||||
|
||||
void MPC::AudioProperties::readSV7(const ByteVector &data, long streamLength) {
|
||||
void MPC::AudioProperties::readSV7(const ByteVector &data, long long streamLength) {
|
||||
|
||||
if (data.startsWith("MP+")) {
|
||||
d->version = data[3] & 15;
|
||||
if (d->version < 7)
|
||||
return;
|
||||
|
||||
d->totalFrames = data.toUInt(4, false);
|
||||
d->totalFrames = data.toUInt32LE(4);
|
||||
|
||||
const unsigned int flags = data.toUInt(8, false);
|
||||
const unsigned int flags = data.toUInt32LE(8);
|
||||
d->sampleRate = sftable[(flags >> 16) & 0x03];
|
||||
d->channels = 2;
|
||||
|
||||
const unsigned int gapless = data.toUInt(5, false);
|
||||
const unsigned int gapless = data.toUInt32LE(5);
|
||||
|
||||
d->trackGain = data.toShort(14, false);
|
||||
d->trackPeak = data.toUShort(12, false);
|
||||
d->albumGain = data.toShort(18, false);
|
||||
d->albumPeak = data.toUShort(16, false);
|
||||
d->trackGain = data.toUInt16LE(14);
|
||||
d->trackPeak = data.toUInt16LE(12);
|
||||
d->albumGain = data.toUInt16LE(18);
|
||||
d->albumPeak = data.toUInt16LE(16);
|
||||
|
||||
// convert gain info
|
||||
if (d->trackGain != 0) {
|
||||
@ -325,7 +327,7 @@ void MPC::AudioProperties::readSV7(const ByteVector &data, long streamLength) {
|
||||
d->sampleFrames = d->totalFrames * 1152 - 576;
|
||||
}
|
||||
else {
|
||||
const unsigned int headerData = data.toUInt(0, false);
|
||||
const unsigned int headerData = data.toUInt32LE(0);
|
||||
|
||||
d->bitrate = (headerData >> 23) & 0x01ff;
|
||||
d->version = (headerData >> 11) & 0x03ff;
|
||||
@ -333,9 +335,9 @@ void MPC::AudioProperties::readSV7(const ByteVector &data, long streamLength) {
|
||||
d->channels = 2;
|
||||
|
||||
if (d->version >= 5)
|
||||
d->totalFrames = data.toUInt(4, false);
|
||||
d->totalFrames = data.toUInt32LE(4);
|
||||
else
|
||||
d->totalFrames = data.toUShort(6, false);
|
||||
d->totalFrames = data.toUInt16LE(6);
|
||||
|
||||
d->sampleFrames = d->totalFrames * 1152 - 576;
|
||||
}
|
||||
|
30
3rdparty/taglib/mpc/mpcproperties.h
vendored
30
3rdparty/taglib/mpc/mpcproperties.h
vendored
@ -36,8 +36,6 @@ namespace MPC {
|
||||
|
||||
class File;
|
||||
|
||||
static const unsigned int HeaderSize = 8 * 7;
|
||||
|
||||
//! An implementation of audio property reading for MPC
|
||||
|
||||
/*!
|
||||
@ -46,22 +44,15 @@ static const unsigned int HeaderSize = 8 * 7;
|
||||
|
||||
class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioProperties {
|
||||
public:
|
||||
/*!
|
||||
* Create an instance of MPC::AudioProperties with the data read from the ByteVector \a data.
|
||||
*
|
||||
* This constructor is deprecated. It only works for MPC version up to 7.
|
||||
*/
|
||||
explicit AudioProperties(const ByteVector &data, long streamLength, ReadStyle style = Average);
|
||||
|
||||
/*!
|
||||
* Create an instance of MPC::AudioProperties with the data read directly from a MPC::File.
|
||||
*/
|
||||
explicit AudioProperties(File *file, long streamLength, ReadStyle style = Average);
|
||||
explicit AudioProperties(File *file, long long streamLength, ReadStyle style = Average);
|
||||
|
||||
/*!
|
||||
* Destroys this MPC::AudioProperties instance.
|
||||
*/
|
||||
virtual ~AudioProperties();
|
||||
~AudioProperties() override;
|
||||
|
||||
/*!
|
||||
* Returns the length of the file in seconds.
|
||||
@ -69,29 +60,29 @@ class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioPro
|
||||
*
|
||||
* \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 version of the bitstream (SV4-SV8)
|
||||
@ -128,11 +119,8 @@ class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioPro
|
||||
int albumPeak() const;
|
||||
|
||||
private:
|
||||
explicit AudioProperties(const AudioProperties&);
|
||||
AudioProperties &operator=(const AudioProperties&);
|
||||
|
||||
void readSV7(const ByteVector &data, long streamLength);
|
||||
void readSV8(File *file, long streamLength);
|
||||
void readSV7(const ByteVector &data, long long streamLength);
|
||||
void readSV8(File *file, long long streamLength);
|
||||
|
||||
class AudioPropertiesPrivate;
|
||||
AudioPropertiesPrivate *d;
|
||||
|
56
3rdparty/taglib/mpeg/id3v1/id3v1tag.cpp
vendored
56
3rdparty/taglib/mpeg/id3v1/id3v1tag.cpp
vendored
@ -23,8 +23,9 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tdebug.h>
|
||||
#include <tfile.h>
|
||||
#include "tdebug.h"
|
||||
#include "tfile.h"
|
||||
#include "tpicturemap.h"
|
||||
|
||||
#include "id3v1tag.h"
|
||||
#include "id3v1genres.h"
|
||||
@ -33,8 +34,24 @@ using namespace Strawberry_TagLib::TagLib;
|
||||
using namespace ID3v1;
|
||||
|
||||
namespace {
|
||||
const ID3v1::StringHandler defaultStringHandler;
|
||||
const ID3v1::StringHandler *stringHandler = &defaultStringHandler;
|
||||
class DefaultStringHandler : public Strawberry_TagLib::TagLib::StringHandler {
|
||||
public:
|
||||
explicit DefaultStringHandler() : Strawberry_TagLib::TagLib::StringHandler() {}
|
||||
|
||||
String parse(const ByteVector &data) const override {
|
||||
return String(data, String::Latin1).stripWhiteSpace();
|
||||
}
|
||||
|
||||
ByteVector render(const String &s) const override {
|
||||
if (s.isLatin1())
|
||||
return s.data(String::Latin1);
|
||||
else
|
||||
return ByteVector();
|
||||
}
|
||||
};
|
||||
|
||||
const DefaultStringHandler defaultStringHandler;
|
||||
const Strawberry_TagLib::TagLib::StringHandler *stringHandler = &defaultStringHandler;
|
||||
} // namespace
|
||||
|
||||
class ID3v1::Tag::TagPrivate {
|
||||
@ -45,7 +62,7 @@ class ID3v1::Tag::TagPrivate {
|
||||
genre(255) {}
|
||||
|
||||
File *file;
|
||||
long tagOffset;
|
||||
long long tagOffset;
|
||||
|
||||
String title;
|
||||
String artist;
|
||||
@ -56,32 +73,13 @@ class ID3v1::Tag::TagPrivate {
|
||||
unsigned char genre;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// StringHandler implementation
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
StringHandler::StringHandler() {}
|
||||
|
||||
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())
|
||||
return s.data(String::Latin1);
|
||||
else
|
||||
return ByteVector();
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// public methods
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ID3v1::Tag::Tag() : d(new TagPrivate()) {}
|
||||
|
||||
ID3v1::Tag::Tag(File *file, long tagOffset) : d(new TagPrivate()) {
|
||||
ID3v1::Tag::Tag(File *file, long long tagOffset) : d(new TagPrivate()) {
|
||||
|
||||
d->file = file;
|
||||
d->tagOffset = tagOffset;
|
||||
@ -143,6 +141,10 @@ unsigned int ID3v1::Tag::track() const {
|
||||
return d->track;
|
||||
}
|
||||
|
||||
Strawberry_TagLib::TagLib::PictureMap ID3v1::Tag::pictures() const {
|
||||
return PictureMap();
|
||||
}
|
||||
|
||||
void ID3v1::Tag::setTitle(const String &s) {
|
||||
d->title = s;
|
||||
}
|
||||
@ -171,6 +173,8 @@ void ID3v1::Tag::setTrack(unsigned int i) {
|
||||
d->track = i < 256 ? i : 0;
|
||||
}
|
||||
|
||||
void ID3v1::Tag::setPictures(const PictureMap&) {}
|
||||
|
||||
unsigned int ID3v1::Tag::genreNumber() const {
|
||||
return d->genre;
|
||||
}
|
||||
@ -179,7 +183,7 @@ void ID3v1::Tag::setGenreNumber(unsigned int i) {
|
||||
d->genre = i < 256 ? i : 255;
|
||||
}
|
||||
|
||||
void ID3v1::Tag::setStringHandler(const StringHandler *handler) {
|
||||
void ID3v1::Tag::setStringHandler(const Strawberry_TagLib::TagLib::StringHandler *handler) {
|
||||
if (handler)
|
||||
stringHandler = handler;
|
||||
else
|
||||
|
78
3rdparty/taglib/mpeg/id3v1/id3v1tag.h
vendored
78
3rdparty/taglib/mpeg/id3v1/id3v1tag.h
vendored
@ -28,6 +28,7 @@
|
||||
|
||||
#include "tag.h"
|
||||
#include "tbytevector.h"
|
||||
#include "tstringhandler.h"
|
||||
#include "taglib_export.h"
|
||||
|
||||
namespace Strawberry_TagLib {
|
||||
@ -39,44 +40,6 @@ class File;
|
||||
|
||||
namespace ID3v1 {
|
||||
|
||||
//! 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.
|
||||
*
|
||||
* However by subclassing this class and reimplementing parse() and render() and setting your reimplementation as the default with
|
||||
* ID3v1::Tag::setStringHandler() you can define how you would like these transformations to be done.
|
||||
*
|
||||
* \warning It is advisable <b>not</b> to write non-ISO-8859-1 data to ID3v1 tags.
|
||||
* Please consider disabling the writing of ID3v1 tags in the case that the data is not ISO-8859-1.
|
||||
*
|
||||
* \see ID3v1::Tag::setStringHandler()
|
||||
*/
|
||||
|
||||
class TAGLIB_EXPORT StringHandler {
|
||||
|
||||
public:
|
||||
explicit StringHandler();
|
||||
virtual ~StringHandler() = default;
|
||||
|
||||
/*!
|
||||
* 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;
|
||||
|
||||
/*!
|
||||
* 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.
|
||||
*
|
||||
* \warning It is recommended that you <b>not</b> override this method, but
|
||||
* 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;
|
||||
};
|
||||
|
||||
//! The main class in the ID3v1 implementation
|
||||
|
||||
/*!
|
||||
@ -106,12 +69,12 @@ class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||
/*!
|
||||
* Create an ID3v1 tag and parse the data in \a file starting at \a tagOffset.
|
||||
*/
|
||||
explicit Tag(File *file, long tagOffset);
|
||||
explicit Tag(File *file, long long tagOffset);
|
||||
|
||||
/*!
|
||||
* Destroys this Tag instance.
|
||||
*/
|
||||
virtual ~Tag();
|
||||
~Tag() override;
|
||||
|
||||
/*!
|
||||
* Renders the in memory values to a ByteVector suitable for writing to the file.
|
||||
@ -125,21 +88,23 @@ class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||
|
||||
// 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;
|
||||
String title() const override;
|
||||
String artist() const override;
|
||||
String album() const override;
|
||||
String comment() const override;
|
||||
String genre() const override;
|
||||
unsigned int year() const override;
|
||||
unsigned int track() const override;
|
||||
PictureMap pictures() const override;
|
||||
|
||||
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);
|
||||
void setTitle(const String &s) override;
|
||||
void setArtist(const String &s) override;
|
||||
void setAlbum(const String &s) override;
|
||||
void setComment(const String &s) override;
|
||||
void setGenre(const String &s) override;
|
||||
void setYear(unsigned int i) override;
|
||||
void setTrack(unsigned int i) override;
|
||||
void setPictures(const PictureMap&) override;
|
||||
|
||||
/*!
|
||||
* Returns the genre in number.
|
||||
@ -161,9 +126,8 @@ class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||
*
|
||||
* \note The caller is responsible for deleting the previous handler as needed after it is released.
|
||||
*
|
||||
* \see StringHandler
|
||||
*/
|
||||
static void setStringHandler(const StringHandler *handler);
|
||||
static void setStringHandler(const Strawberry_TagLib::TagLib::StringHandler *handler);
|
||||
|
||||
protected:
|
||||
/*!
|
||||
@ -176,7 +140,7 @@ class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||
void parse(const ByteVector &data);
|
||||
|
||||
private:
|
||||
explicit Tag(const Tag&);
|
||||
Tag(const Tag&);
|
||||
Tag &operator=(const Tag&);
|
||||
|
||||
class TagPrivate;
|
||||
|
@ -25,15 +25,15 @@
|
||||
|
||||
#include "attachedpictureframe.h"
|
||||
|
||||
#include <tstringlist.h>
|
||||
#include <tdebug.h>
|
||||
#include "tstringlist.h"
|
||||
#include "tdebug.h"
|
||||
|
||||
using namespace Strawberry_TagLib::TagLib;
|
||||
using namespace ID3v2;
|
||||
|
||||
class AttachedPictureFrame::AttachedPictureFramePrivate {
|
||||
public:
|
||||
AttachedPictureFramePrivate() : textEncoding(String::Latin1), type(AttachedPictureFrame::Other) {}
|
||||
explicit AttachedPictureFramePrivate() : textEncoding(String::Latin1), type(AttachedPictureFrame::Other) {}
|
||||
|
||||
String::Type textEncoding;
|
||||
String mimeType;
|
||||
@ -114,17 +114,17 @@ void AttachedPictureFrame::parseFields(const ByteVector &data) {
|
||||
|
||||
d->textEncoding = String::Type(data[0]);
|
||||
|
||||
int pos = 1;
|
||||
size_t pos = 1;
|
||||
|
||||
d->mimeType = readStringField(data, String::Latin1, &pos);
|
||||
d->mimeType = readStringField(data, String::Latin1, pos);
|
||||
/* Now we need at least two more bytes available */
|
||||
if (static_cast<unsigned int>(pos) + 1 >= data.size()) {
|
||||
if (pos + 1 >= data.size()) {
|
||||
debug("Truncated picture frame.");
|
||||
return;
|
||||
}
|
||||
|
||||
d->type = static_cast<ID3v2::AttachedPictureFrame::Type>(data[pos++]);
|
||||
d->description = readStringField(data, d->textEncoding, &pos);
|
||||
d->description = readStringField(data, d->textEncoding, pos);
|
||||
|
||||
d->data = data.mid(pos);
|
||||
|
||||
@ -169,7 +169,7 @@ void AttachedPictureFrameV22::parseFields(const ByteVector &data) {
|
||||
|
||||
d->textEncoding = String::Type(data[0]);
|
||||
|
||||
int pos = 1;
|
||||
size_t pos = 1;
|
||||
|
||||
String fixedString = String(data.mid(pos, 3), String::Latin1);
|
||||
pos += 3;
|
||||
@ -186,7 +186,7 @@ void AttachedPictureFrameV22::parseFields(const ByteVector &data) {
|
||||
}
|
||||
|
||||
d->type = static_cast<ID3v2::AttachedPictureFrame::Type>(data[pos++]);
|
||||
d->description = readStringField(data, d->textEncoding, &pos);
|
||||
d->description = readStringField(data, d->textEncoding, pos);
|
||||
|
||||
d->data = data.mid(pos);
|
||||
|
||||
|
@ -108,12 +108,12 @@ class TAGLIB_EXPORT AttachedPictureFrame : public Frame {
|
||||
/*!
|
||||
* Destroys the AttahcedPictureFrame instance.
|
||||
*/
|
||||
virtual ~AttachedPictureFrame();
|
||||
~AttachedPictureFrame() override;
|
||||
|
||||
/*!
|
||||
* Returns a string containing the description and mime-type
|
||||
*/
|
||||
virtual String toString() const;
|
||||
String toString() const override;
|
||||
|
||||
/*!
|
||||
* Returns the text encoding used for the description.
|
||||
@ -198,13 +198,13 @@ class TAGLIB_EXPORT AttachedPictureFrame : public Frame {
|
||||
void setPicture(const ByteVector &p);
|
||||
|
||||
protected:
|
||||
virtual void parseFields(const ByteVector &data);
|
||||
virtual ByteVector renderFields() const;
|
||||
void parseFields(const ByteVector &data) override;
|
||||
ByteVector renderFields() const override;
|
||||
class AttachedPictureFramePrivate;
|
||||
AttachedPictureFramePrivate *d;
|
||||
|
||||
private:
|
||||
explicit AttachedPictureFrame(const AttachedPictureFrame&);
|
||||
AttachedPictureFrame(const AttachedPictureFrame&);
|
||||
AttachedPictureFrame &operator=(const AttachedPictureFrame&);
|
||||
explicit AttachedPictureFrame(const ByteVector &data, Header *h);
|
||||
};
|
||||
@ -212,7 +212,7 @@ class TAGLIB_EXPORT AttachedPictureFrame : public Frame {
|
||||
//! support for ID3v2.2 PIC frames
|
||||
class TAGLIB_EXPORT AttachedPictureFrameV22 : public AttachedPictureFrame {
|
||||
protected:
|
||||
virtual void parseFields(const ByteVector &data);
|
||||
void parseFields(const ByteVector &data) override;
|
||||
|
||||
private:
|
||||
explicit AttachedPictureFrameV22(const ByteVector &data, Header *h);
|
||||
|
@ -25,9 +25,9 @@
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include <tbytevectorlist.h>
|
||||
#include <tpropertymap.h>
|
||||
#include <tdebug.h>
|
||||
#include "tbytevectorlist.h"
|
||||
#include "tpropertymap.h"
|
||||
#include "tdebug.h"
|
||||
|
||||
#include "chapterframe.h"
|
||||
|
||||
@ -36,11 +36,11 @@ using namespace ID3v2;
|
||||
|
||||
class ChapterFrame::ChapterFramePrivate {
|
||||
public:
|
||||
ChapterFramePrivate() : tagHeader(nullptr),
|
||||
startTime(0),
|
||||
endTime(0),
|
||||
startOffset(0),
|
||||
endOffset(0) {
|
||||
explicit ChapterFramePrivate() : tagHeader(nullptr),
|
||||
startTime(0),
|
||||
endTime(0),
|
||||
startOffset(0),
|
||||
endOffset(0) {
|
||||
embeddedFrameList.setAutoDelete(true);
|
||||
}
|
||||
|
||||
@ -224,23 +224,23 @@ ChapterFrame *ChapterFrame::findByElementID(const ID3v2::Tag *tag, const ByteVec
|
||||
|
||||
void ChapterFrame::parseFields(const ByteVector &data) {
|
||||
|
||||
unsigned int size = data.size();
|
||||
size_t size = data.size();
|
||||
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;
|
||||
}
|
||||
|
||||
int pos = 0;
|
||||
unsigned int embPos = 0;
|
||||
d->elementID = readStringField(data, String::Latin1, &pos).data(String::Latin1);
|
||||
d->startTime = data.toUInt(pos, true);
|
||||
size_t pos = 0;
|
||||
size_t embPos = 0;
|
||||
d->elementID = readStringField(data, String::Latin1, pos).data(String::Latin1);
|
||||
d->startTime = data.toUInt32BE(pos);
|
||||
pos += 4;
|
||||
d->endTime = data.toUInt(pos, true);
|
||||
d->endTime = data.toUInt32BE(pos);
|
||||
pos += 4;
|
||||
d->startOffset = data.toUInt(pos, true);
|
||||
d->startOffset = data.toUInt32BE(pos);
|
||||
pos += 4;
|
||||
d->endOffset = data.toUInt(pos, true);
|
||||
d->endOffset = data.toUInt32BE(pos);
|
||||
pos += 4;
|
||||
size -= pos;
|
||||
|
||||
@ -273,10 +273,10 @@ ByteVector ChapterFrame::renderFields() const {
|
||||
|
||||
data.append(d->elementID);
|
||||
data.append('\0');
|
||||
data.append(ByteVector::fromUInt(d->startTime, true));
|
||||
data.append(ByteVector::fromUInt(d->endTime, true));
|
||||
data.append(ByteVector::fromUInt(d->startOffset, true));
|
||||
data.append(ByteVector::fromUInt(d->endOffset, true));
|
||||
data.append(ByteVector::fromUInt32BE(d->startTime));
|
||||
data.append(ByteVector::fromUInt32BE(d->endTime));
|
||||
data.append(ByteVector::fromUInt32BE(d->startOffset));
|
||||
data.append(ByteVector::fromUInt32BE(d->endOffset));
|
||||
FrameList l = d->embeddedFrameList;
|
||||
for (FrameList::ConstIterator it = l.begin(); it != l.end(); ++it)
|
||||
data.append((*it)->render());
|
||||
|
10
3rdparty/taglib/mpeg/id3v2/frames/chapterframe.h
vendored
10
3rdparty/taglib/mpeg/id3v2/frames/chapterframe.h
vendored
@ -64,7 +64,7 @@ class TAGLIB_EXPORT ChapterFrame : public ID3v2::Frame {
|
||||
/*!
|
||||
* Destroys the frame.
|
||||
*/
|
||||
virtual ~ChapterFrame();
|
||||
~ChapterFrame() override;
|
||||
|
||||
/*!
|
||||
* Returns the element ID of the frame.
|
||||
@ -201,7 +201,7 @@ class TAGLIB_EXPORT ChapterFrame : public ID3v2::Frame {
|
||||
*/
|
||||
void removeEmbeddedFrames(const ByteVector &id);
|
||||
|
||||
virtual String toString() const;
|
||||
String toString() const override;
|
||||
|
||||
PropertyMap asProperties() const;
|
||||
|
||||
@ -214,12 +214,12 @@ class TAGLIB_EXPORT ChapterFrame : public ID3v2::Frame {
|
||||
static ChapterFrame *findByElementID(const Tag *tag, const ByteVector &eID);
|
||||
|
||||
protected:
|
||||
virtual void parseFields(const ByteVector &data);
|
||||
virtual ByteVector renderFields() const;
|
||||
void parseFields(const ByteVector &data) override;
|
||||
ByteVector renderFields() const override;
|
||||
|
||||
private:
|
||||
explicit ChapterFrame(const ID3v2::Header *tagHeader, const ByteVector &data, Header *h);
|
||||
explicit ChapterFrame(const ChapterFrame&);
|
||||
ChapterFrame(const ChapterFrame&);
|
||||
ChapterFrame &operator=(const ChapterFrame&);
|
||||
|
||||
class ChapterFramePrivate;
|
||||
|
@ -23,10 +23,10 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tbytevectorlist.h>
|
||||
#include <id3v2tag.h>
|
||||
#include <tdebug.h>
|
||||
#include <tstringlist.h>
|
||||
#include "tbytevectorlist.h"
|
||||
#include "id3v2tag.h"
|
||||
#include "tdebug.h"
|
||||
#include "tstringlist.h"
|
||||
|
||||
#include "commentsframe.h"
|
||||
#include "tpropertymap.h"
|
||||
@ -36,7 +36,7 @@ using namespace ID3v2;
|
||||
|
||||
class CommentsFrame::CommentsFramePrivate {
|
||||
public:
|
||||
CommentsFramePrivate() : textEncoding(String::Latin1) {}
|
||||
explicit CommentsFramePrivate() : textEncoding(String::Latin1) {}
|
||||
String::Type textEncoding;
|
||||
ByteVector language;
|
||||
String description;
|
||||
|
@ -57,14 +57,14 @@ class TAGLIB_EXPORT CommentsFrame : public Frame {
|
||||
/*!
|
||||
* Destroys this CommentFrame instance.
|
||||
*/
|
||||
virtual ~CommentsFrame();
|
||||
~CommentsFrame() override;
|
||||
|
||||
/*!
|
||||
* Returns the text of this comment.
|
||||
*
|
||||
* \see text()
|
||||
*/
|
||||
virtual String toString() const;
|
||||
String toString() const override;
|
||||
|
||||
/*!
|
||||
* Returns the language encoding as a 3 byte encoding as specified by
|
||||
@ -112,7 +112,7 @@ class TAGLIB_EXPORT CommentsFrame : public Frame {
|
||||
*
|
||||
* \see text()
|
||||
*/
|
||||
virtual void setText(const String &s);
|
||||
void setText(const String &s) override;
|
||||
|
||||
/*!
|
||||
* Returns the text encoding that will be used in rendering this frame.
|
||||
@ -154,15 +154,15 @@ class TAGLIB_EXPORT CommentsFrame : public Frame {
|
||||
protected:
|
||||
// Reimplementations.
|
||||
|
||||
virtual void parseFields(const ByteVector &data);
|
||||
virtual ByteVector renderFields() const;
|
||||
void parseFields(const ByteVector &data) override;
|
||||
ByteVector renderFields() const override;
|
||||
|
||||
private:
|
||||
/*!
|
||||
* The constructor used by the FrameFactory.
|
||||
*/
|
||||
explicit CommentsFrame(const ByteVector &data, Header *h);
|
||||
explicit CommentsFrame(const CommentsFrame &);
|
||||
CommentsFrame(const CommentsFrame &);
|
||||
CommentsFrame &operator=(const CommentsFrame &);
|
||||
|
||||
class CommentsFramePrivate;
|
||||
|
@ -24,17 +24,17 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "eventtimingcodesframe.h"
|
||||
#include <tbytevectorlist.h>
|
||||
#include <id3v2tag.h>
|
||||
#include <tdebug.h>
|
||||
#include <tpropertymap.h>
|
||||
#include "tbytevectorlist.h"
|
||||
#include "id3v2tag.h"
|
||||
#include "tdebug.h"
|
||||
#include "tpropertymap.h"
|
||||
|
||||
using namespace Strawberry_TagLib::TagLib;
|
||||
using namespace ID3v2;
|
||||
|
||||
class EventTimingCodesFrame::EventTimingCodesFramePrivate {
|
||||
public:
|
||||
EventTimingCodesFramePrivate() : timestampFormat(EventTimingCodesFrame::AbsoluteMilliseconds) {}
|
||||
explicit EventTimingCodesFramePrivate() : timestampFormat(EventTimingCodesFrame::AbsoluteMilliseconds) {}
|
||||
EventTimingCodesFrame::TimestampFormat timestampFormat;
|
||||
EventTimingCodesFrame::SynchedEventList synchedEvents;
|
||||
};
|
||||
@ -83,7 +83,7 @@ void EventTimingCodesFrame::setSynchedEvents(
|
||||
|
||||
void EventTimingCodesFrame::parseFields(const ByteVector &data) {
|
||||
|
||||
const int end = data.size();
|
||||
const size_t end = data.size();
|
||||
if (end < 1) {
|
||||
debug("An event timing codes frame must contain at least 1 byte.");
|
||||
return;
|
||||
@ -91,11 +91,11 @@ void EventTimingCodesFrame::parseFields(const ByteVector &data) {
|
||||
|
||||
d->timestampFormat = TimestampFormat(data[0]);
|
||||
|
||||
int pos = 1;
|
||||
size_t pos = 1;
|
||||
d->synchedEvents.clear();
|
||||
while (pos + 4 < end) {
|
||||
EventType type = static_cast<EventType>(static_cast<unsigned char>(data[pos++]));
|
||||
unsigned int time = data.toUInt(pos, true);
|
||||
unsigned int time = data.toUInt32BE(pos);
|
||||
pos += 4;
|
||||
d->synchedEvents.append(SynchedEvent(time, type));
|
||||
}
|
||||
@ -110,7 +110,7 @@ ByteVector EventTimingCodesFrame::renderFields() const {
|
||||
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));
|
||||
v.append(ByteVector::fromUInt32BE(entry.time));
|
||||
}
|
||||
|
||||
return v;
|
||||
|
@ -129,12 +129,12 @@ class TAGLIB_EXPORT EventTimingCodesFrame : public Frame {
|
||||
/*!
|
||||
* Destroys this EventTimingCodesFrame instance.
|
||||
*/
|
||||
virtual ~EventTimingCodesFrame();
|
||||
~EventTimingCodesFrame() override;
|
||||
|
||||
/*!
|
||||
* Returns a null string.
|
||||
*/
|
||||
virtual String toString() const;
|
||||
String toString() const override;
|
||||
|
||||
/*!
|
||||
* Returns the timestamp format.
|
||||
@ -163,15 +163,15 @@ class TAGLIB_EXPORT EventTimingCodesFrame : public Frame {
|
||||
protected:
|
||||
// Reimplementations.
|
||||
|
||||
virtual void parseFields(const ByteVector &data);
|
||||
virtual ByteVector renderFields() const;
|
||||
void parseFields(const ByteVector &data) override;
|
||||
ByteVector renderFields() const override;
|
||||
|
||||
private:
|
||||
/*!
|
||||
* The constructor used by the FrameFactory.
|
||||
*/
|
||||
explicit EventTimingCodesFrame(const ByteVector &data, Header *h);
|
||||
explicit EventTimingCodesFrame(const EventTimingCodesFrame&);
|
||||
EventTimingCodesFrame(const EventTimingCodesFrame&);
|
||||
EventTimingCodesFrame &operator=(const EventTimingCodesFrame&);
|
||||
|
||||
class EventTimingCodesFramePrivate;
|
||||
|
@ -26,8 +26,8 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tdebug.h>
|
||||
#include <tstringlist.h>
|
||||
#include "tdebug.h"
|
||||
#include "tstringlist.h"
|
||||
|
||||
#include "generalencapsulatedobjectframe.h"
|
||||
|
||||
@ -36,7 +36,7 @@ using namespace ID3v2;
|
||||
|
||||
class GeneralEncapsulatedObjectFrame::GeneralEncapsulatedObjectFramePrivate {
|
||||
public:
|
||||
GeneralEncapsulatedObjectFramePrivate() : textEncoding(String::Latin1) {}
|
||||
explicit GeneralEncapsulatedObjectFramePrivate() : textEncoding(String::Latin1) {}
|
||||
|
||||
String::Type textEncoding;
|
||||
String mimeType;
|
||||
@ -126,11 +126,11 @@ void GeneralEncapsulatedObjectFrame::parseFields(const ByteVector &data) {
|
||||
|
||||
d->textEncoding = String::Type(data[0]);
|
||||
|
||||
int pos = 1;
|
||||
size_t pos = 1;
|
||||
|
||||
d->mimeType = readStringField(data, String::Latin1, &pos);
|
||||
d->fileName = readStringField(data, d->textEncoding, &pos);
|
||||
d->description = readStringField(data, d->textEncoding, &pos);
|
||||
d->mimeType = readStringField(data, String::Latin1, pos);
|
||||
d->fileName = readStringField(data, d->textEncoding, pos);
|
||||
d->description = readStringField(data, d->textEncoding, pos);
|
||||
|
||||
d->data = data.mid(pos);
|
||||
|
||||
|
@ -70,12 +70,12 @@ class TAGLIB_EXPORT GeneralEncapsulatedObjectFrame : public Frame {
|
||||
/*!
|
||||
* Destroys the GeneralEncapsulatedObjectFrame instance.
|
||||
*/
|
||||
virtual ~GeneralEncapsulatedObjectFrame();
|
||||
~GeneralEncapsulatedObjectFrame() override;
|
||||
|
||||
/*!
|
||||
* Returns a string containing the description, file name and mime-type
|
||||
*/
|
||||
virtual String toString() const;
|
||||
String toString() const override;
|
||||
|
||||
/*!
|
||||
* Returns the text encoding used for the description and file name.
|
||||
@ -160,12 +160,12 @@ class TAGLIB_EXPORT GeneralEncapsulatedObjectFrame : public Frame {
|
||||
void setObject(const ByteVector &data);
|
||||
|
||||
protected:
|
||||
virtual void parseFields(const ByteVector &data);
|
||||
virtual ByteVector renderFields() const;
|
||||
void parseFields(const ByteVector &data) override;
|
||||
ByteVector renderFields() const override;
|
||||
|
||||
private:
|
||||
explicit GeneralEncapsulatedObjectFrame(const ByteVector &data, Header *h);
|
||||
explicit GeneralEncapsulatedObjectFrame(const GeneralEncapsulatedObjectFrame&);
|
||||
GeneralEncapsulatedObjectFrame(const GeneralEncapsulatedObjectFrame&);
|
||||
GeneralEncapsulatedObjectFrame &operator=(const GeneralEncapsulatedObjectFrame&);
|
||||
|
||||
class GeneralEncapsulatedObjectFramePrivate;
|
||||
|
@ -23,9 +23,9 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tdebug.h>
|
||||
#include <tstringlist.h>
|
||||
#include <id3v2tag.h>
|
||||
#include "tdebug.h"
|
||||
#include "tstringlist.h"
|
||||
#include "id3v2tag.h"
|
||||
|
||||
#include "ownershipframe.h"
|
||||
|
||||
@ -98,14 +98,14 @@ void OwnershipFrame::setTextEncoding(String::Type encoding) {
|
||||
|
||||
void OwnershipFrame::parseFields(const ByteVector &data) {
|
||||
|
||||
int pos = 0;
|
||||
size_t pos = 0;
|
||||
|
||||
// Get the text encoding
|
||||
d->textEncoding = String::Type(data[0]);
|
||||
pos += 1;
|
||||
|
||||
// Read the price paid this is a null terminate string
|
||||
d->pricePaid = readStringField(data, String::Latin1, &pos);
|
||||
d->pricePaid = readStringField(data, String::Latin1, pos);
|
||||
|
||||
// If we don't have at least 8 bytes left then don't parse the rest of the
|
||||
// data
|
||||
|
@ -57,14 +57,14 @@ class TAGLIB_EXPORT OwnershipFrame : public Frame {
|
||||
/*!
|
||||
* Destroys this OwnershipFrame instance.
|
||||
*/
|
||||
virtual ~OwnershipFrame();
|
||||
~OwnershipFrame() override;
|
||||
|
||||
/*!
|
||||
* Returns the text of this popularimeter.
|
||||
*
|
||||
* \see text()
|
||||
*/
|
||||
virtual String toString() const;
|
||||
String toString() const override;
|
||||
|
||||
/*!
|
||||
* Returns the date purchased.
|
||||
@ -128,15 +128,15 @@ class TAGLIB_EXPORT OwnershipFrame : public Frame {
|
||||
protected:
|
||||
// Reimplementations.
|
||||
|
||||
virtual void parseFields(const ByteVector &data);
|
||||
virtual ByteVector renderFields() const;
|
||||
void parseFields(const ByteVector &data) override;
|
||||
ByteVector renderFields() const override;
|
||||
|
||||
private:
|
||||
/*!
|
||||
* The constructor used by the FrameFactory.
|
||||
*/
|
||||
explicit OwnershipFrame(const ByteVector &data, Header *h);
|
||||
explicit OwnershipFrame(const OwnershipFrame&);
|
||||
OwnershipFrame(const OwnershipFrame&);
|
||||
OwnershipFrame &operator=(const OwnershipFrame &);
|
||||
|
||||
class OwnershipFramePrivate;
|
||||
|
10
3rdparty/taglib/mpeg/id3v2/frames/podcastframe.h
vendored
10
3rdparty/taglib/mpeg/id3v2/frames/podcastframe.h
vendored
@ -49,25 +49,25 @@ class TAGLIB_EXPORT PodcastFrame : public Frame {
|
||||
/*!
|
||||
* Destroys this PodcastFrame instance.
|
||||
*/
|
||||
virtual ~PodcastFrame();
|
||||
~PodcastFrame() override;
|
||||
|
||||
/*!
|
||||
* Returns a null string.
|
||||
*/
|
||||
virtual String toString() const;
|
||||
String toString() const override;
|
||||
|
||||
protected:
|
||||
// Reimplementations.
|
||||
|
||||
virtual void parseFields(const ByteVector &data);
|
||||
virtual ByteVector renderFields() const;
|
||||
void parseFields(const ByteVector &data) override;
|
||||
ByteVector renderFields() const override;
|
||||
|
||||
private:
|
||||
/*!
|
||||
* The constructor used by the FrameFactory.
|
||||
*/
|
||||
explicit PodcastFrame(const ByteVector &data, Header *h);
|
||||
explicit PodcastFrame(const PodcastFrame &);
|
||||
PodcastFrame(const PodcastFrame &);
|
||||
PodcastFrame &operator=(const PodcastFrame &);
|
||||
|
||||
class PodcastFramePrivate;
|
||||
|
@ -23,7 +23,7 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tdebug.h>
|
||||
#include "tdebug.h"
|
||||
|
||||
#include "popularimeterframe.h"
|
||||
|
||||
@ -32,7 +32,7 @@ using namespace ID3v2;
|
||||
|
||||
class PopularimeterFrame::PopularimeterFramePrivate {
|
||||
public:
|
||||
PopularimeterFramePrivate() : rating(0), counter(0) {}
|
||||
explicit PopularimeterFramePrivate() : rating(0), counter(0) {}
|
||||
String email;
|
||||
int rating;
|
||||
unsigned int counter;
|
||||
@ -86,16 +86,17 @@ void PopularimeterFrame::setCounter(unsigned int counter) {
|
||||
|
||||
void PopularimeterFrame::parseFields(const ByteVector &data) {
|
||||
|
||||
int pos = 0, size = int(data.size());
|
||||
size_t pos = 0;
|
||||
const size_t size = data.size();
|
||||
|
||||
d->email = readStringField(data, String::Latin1, &pos);
|
||||
d->email = readStringField(data, String::Latin1, pos);
|
||||
|
||||
d->rating = 0;
|
||||
d->counter = 0;
|
||||
if (pos < size) {
|
||||
d->rating = static_cast<unsigned char>(data[pos++]);
|
||||
if (pos < size) {
|
||||
d->counter = data.toUInt(static_cast<unsigned int>(pos));
|
||||
d->counter = data.toUInt32BE(pos);
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,7 +109,7 @@ ByteVector PopularimeterFrame::renderFields() const {
|
||||
data.append(d->email.data(String::Latin1));
|
||||
data.append(textDelimiter(String::Latin1));
|
||||
data.append(char(d->rating));
|
||||
data.append(ByteVector::fromUInt(d->counter));
|
||||
data.append(ByteVector::fromUInt32BE(d->counter));
|
||||
|
||||
return data;
|
||||
|
||||
|
@ -57,14 +57,14 @@ class TAGLIB_EXPORT PopularimeterFrame : public Frame {
|
||||
/*!
|
||||
* Destroys this PopularimeterFrame instance.
|
||||
*/
|
||||
virtual ~PopularimeterFrame();
|
||||
~PopularimeterFrame() override;
|
||||
|
||||
/*!
|
||||
* Returns the text of this popularimeter.
|
||||
*
|
||||
* \see text()
|
||||
*/
|
||||
virtual String toString() const;
|
||||
String toString() const override;
|
||||
|
||||
/*!
|
||||
* Returns the email.
|
||||
@ -111,15 +111,15 @@ class TAGLIB_EXPORT PopularimeterFrame : public Frame {
|
||||
protected:
|
||||
// Reimplementations.
|
||||
|
||||
virtual void parseFields(const ByteVector &data);
|
||||
virtual ByteVector renderFields() const;
|
||||
void parseFields(const ByteVector &data) override;
|
||||
ByteVector renderFields() const override;
|
||||
|
||||
private:
|
||||
/*!
|
||||
* The constructor used by the FrameFactory.
|
||||
*/
|
||||
explicit PopularimeterFrame(const ByteVector &data, Header *h);
|
||||
explicit PopularimeterFrame(const PopularimeterFrame&);
|
||||
PopularimeterFrame(const PopularimeterFrame&);
|
||||
PopularimeterFrame &operator=(const PopularimeterFrame&);
|
||||
|
||||
class PopularimeterFramePrivate;
|
||||
|
@ -24,9 +24,9 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tbytevectorlist.h>
|
||||
#include <id3v2tag.h>
|
||||
#include <tdebug.h>
|
||||
#include "tbytevectorlist.h"
|
||||
#include "id3v2tag.h"
|
||||
#include "tdebug.h"
|
||||
|
||||
#include "privateframe.h"
|
||||
|
||||
@ -87,8 +87,7 @@ void PrivateFrame::parseFields(const ByteVector &data) {
|
||||
|
||||
// Owner identifier is assumed to be Latin1
|
||||
|
||||
const int byteAlign = 1;
|
||||
const int endOfOwner = data.find(textDelimiter(String::Latin1), 0, byteAlign);
|
||||
const size_t endOfOwner = data.find(textDelimiter(String::Latin1), 0, 1);
|
||||
|
||||
d->owner = String(data.mid(0, endOfOwner));
|
||||
d->data = data.mid(endOfOwner + 1);
|
||||
|
10
3rdparty/taglib/mpeg/id3v2/frames/privateframe.h
vendored
10
3rdparty/taglib/mpeg/id3v2/frames/privateframe.h
vendored
@ -55,14 +55,14 @@ class TAGLIB_EXPORT PrivateFrame : public Frame {
|
||||
/*!
|
||||
* Destroys this private frame instance.
|
||||
*/
|
||||
virtual ~PrivateFrame();
|
||||
~PrivateFrame() override;
|
||||
|
||||
/*!
|
||||
* Returns the text of this private frame, currently just the owner.
|
||||
*
|
||||
* \see text()
|
||||
*/
|
||||
virtual String toString() const;
|
||||
String toString() const override;
|
||||
|
||||
/*!
|
||||
* \return The owner of the private frame.
|
||||
@ -89,8 +89,8 @@ class TAGLIB_EXPORT PrivateFrame : public Frame {
|
||||
protected:
|
||||
// Reimplementations.
|
||||
|
||||
virtual void parseFields(const ByteVector &data);
|
||||
virtual ByteVector renderFields() const;
|
||||
void parseFields(const ByteVector &data) override;
|
||||
ByteVector renderFields() const override;
|
||||
|
||||
private:
|
||||
/*!
|
||||
@ -98,7 +98,7 @@ class TAGLIB_EXPORT PrivateFrame : public Frame {
|
||||
*/
|
||||
explicit PrivateFrame(const ByteVector &data, Header *h);
|
||||
|
||||
explicit PrivateFrame(const PrivateFrame&);
|
||||
PrivateFrame(const PrivateFrame&);
|
||||
PrivateFrame &operator=(const PrivateFrame&);
|
||||
|
||||
class PrivateFramePrivate;
|
||||
|
@ -23,21 +23,23 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tdebug.h>
|
||||
#include <tmap.h>
|
||||
#include "tdebug.h"
|
||||
#include "tmap.h"
|
||||
|
||||
#include "relativevolumeframe.h"
|
||||
|
||||
using namespace Strawberry_TagLib::TagLib;
|
||||
using namespace ID3v2;
|
||||
|
||||
namespace {
|
||||
struct ChannelData {
|
||||
ChannelData() : channelType(RelativeVolumeFrame::Other), volumeAdjustment(0) {}
|
||||
explicit ChannelData() : channelType(RelativeVolumeFrame::Other), volumeAdjustment(0) {}
|
||||
|
||||
RelativeVolumeFrame::ChannelType channelType;
|
||||
short volumeAdjustment;
|
||||
RelativeVolumeFrame::PeakVolume peakVolume;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
class RelativeVolumeFrame::RelativeVolumeFramePrivate {
|
||||
public:
|
||||
@ -79,50 +81,26 @@ short RelativeVolumeFrame::volumeAdjustmentIndex(ChannelType type) const {
|
||||
return d->channels.contains(type) ? d->channels[type].volumeAdjustment : 0;
|
||||
}
|
||||
|
||||
short RelativeVolumeFrame::volumeAdjustmentIndex() const {
|
||||
return volumeAdjustmentIndex(MasterVolume);
|
||||
}
|
||||
|
||||
void RelativeVolumeFrame::setVolumeAdjustmentIndex(short index, ChannelType type) {
|
||||
d->channels[type].volumeAdjustment = index;
|
||||
}
|
||||
|
||||
void RelativeVolumeFrame::setVolumeAdjustmentIndex(short index) {
|
||||
setVolumeAdjustmentIndex(index, MasterVolume);
|
||||
}
|
||||
|
||||
float RelativeVolumeFrame::volumeAdjustment(ChannelType type) const {
|
||||
return d->channels.contains(type) ? float(d->channels[type].volumeAdjustment) / float(512) : 0;
|
||||
}
|
||||
|
||||
float RelativeVolumeFrame::volumeAdjustment() const {
|
||||
return volumeAdjustment(MasterVolume);
|
||||
}
|
||||
|
||||
void RelativeVolumeFrame::setVolumeAdjustment(float adjustment, ChannelType type) {
|
||||
d->channels[type].volumeAdjustment = short(adjustment * float(512));
|
||||
}
|
||||
|
||||
void RelativeVolumeFrame::setVolumeAdjustment(float adjustment) {
|
||||
setVolumeAdjustment(adjustment, MasterVolume);
|
||||
}
|
||||
|
||||
RelativeVolumeFrame::PeakVolume RelativeVolumeFrame::peakVolume(ChannelType type) const {
|
||||
return d->channels.contains(type) ? d->channels[type].peakVolume : PeakVolume();
|
||||
}
|
||||
|
||||
RelativeVolumeFrame::PeakVolume RelativeVolumeFrame::peakVolume() const {
|
||||
return peakVolume(MasterVolume);
|
||||
}
|
||||
|
||||
void RelativeVolumeFrame::setPeakVolume(const PeakVolume &peak, ChannelType type) {
|
||||
d->channels[type].peakVolume = peak;
|
||||
}
|
||||
|
||||
void RelativeVolumeFrame::setPeakVolume(const PeakVolume &peak) {
|
||||
setPeakVolume(peak, MasterVolume);
|
||||
}
|
||||
|
||||
String RelativeVolumeFrame::identification() const {
|
||||
return d->identification;
|
||||
}
|
||||
@ -137,19 +115,19 @@ void RelativeVolumeFrame::setIdentification(const String &s) {
|
||||
|
||||
void RelativeVolumeFrame::parseFields(const ByteVector &data) {
|
||||
|
||||
int pos = 0;
|
||||
d->identification = readStringField(data, String::Latin1, &pos);
|
||||
size_t pos = 0;
|
||||
d->identification = readStringField(data, String::Latin1, pos);
|
||||
|
||||
// Each channel is at least 4 bytes.
|
||||
|
||||
while (pos <= static_cast<int>(data.size()) - 4) {
|
||||
while (pos + 4 <= data.size()) {
|
||||
|
||||
ChannelType type = ChannelType(data[pos]);
|
||||
pos += 1;
|
||||
|
||||
ChannelData &channel = d->channels[type];
|
||||
|
||||
channel.volumeAdjustment = data.toShort(static_cast<unsigned int>(pos));
|
||||
channel.volumeAdjustment = data.toInt16BE(pos);
|
||||
pos += 2;
|
||||
|
||||
channel.peakVolume.bitsRepresentingPeak = data[pos];
|
||||
@ -176,7 +154,7 @@ ByteVector RelativeVolumeFrame::renderFields() const {
|
||||
const ChannelData &channel = (*it).second;
|
||||
|
||||
data.append(char(type));
|
||||
data.append(ByteVector::fromShort(channel.volumeAdjustment));
|
||||
data.append(ByteVector::fromUInt16BE(channel.volumeAdjustment));
|
||||
data.append(char(channel.peakVolume.bitsRepresentingPeak));
|
||||
data.append(channel.peakVolume.peakVolume);
|
||||
}
|
||||
|
@ -105,26 +105,20 @@ class TAGLIB_EXPORT RelativeVolumeFrame : public Frame {
|
||||
/*!
|
||||
* Destroys the RelativeVolumeFrame instance.
|
||||
*/
|
||||
virtual ~RelativeVolumeFrame();
|
||||
~RelativeVolumeFrame() override;
|
||||
|
||||
/*!
|
||||
* Returns the frame's identification.
|
||||
*
|
||||
* \see identification()
|
||||
*/
|
||||
virtual String toString() const;
|
||||
String toString() const override;
|
||||
|
||||
/*!
|
||||
* Returns a list of channels with information currently in the frame.
|
||||
*/
|
||||
List<ChannelType> channels() const;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#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.
|
||||
@ -190,30 +184,6 @@ class TAGLIB_EXPORT RelativeVolumeFrame : public Frame {
|
||||
*/
|
||||
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).
|
||||
|
||||
short volumeAdjustmentIndex(ChannelType type) const;
|
||||
short volumeAdjustmentIndex() const;
|
||||
|
||||
void setVolumeAdjustmentIndex(short index, ChannelType type);
|
||||
void setVolumeAdjustmentIndex(short index);
|
||||
|
||||
float volumeAdjustment(ChannelType type) const;
|
||||
float volumeAdjustment() const;
|
||||
|
||||
void setVolumeAdjustment(float adjustment, ChannelType type);
|
||||
void setVolumeAdjustment(float adjustment);
|
||||
|
||||
PeakVolume peakVolume(ChannelType type) const;
|
||||
PeakVolume peakVolume() const;
|
||||
|
||||
void setPeakVolume(const PeakVolume &peak, ChannelType type);
|
||||
void setPeakVolume(const PeakVolume &peak);
|
||||
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* Returns the identification for this frame.
|
||||
*/
|
||||
@ -226,12 +196,12 @@ class TAGLIB_EXPORT RelativeVolumeFrame : public Frame {
|
||||
void setIdentification(const String &s);
|
||||
|
||||
protected:
|
||||
virtual void parseFields(const ByteVector &data);
|
||||
virtual ByteVector renderFields() const;
|
||||
void parseFields(const ByteVector &data) override;
|
||||
ByteVector renderFields() const override;
|
||||
|
||||
private:
|
||||
explicit RelativeVolumeFrame(const ByteVector &data, Header *h);
|
||||
explicit RelativeVolumeFrame(const RelativeVolumeFrame&);
|
||||
RelativeVolumeFrame(const RelativeVolumeFrame&);
|
||||
RelativeVolumeFrame &operator=(const RelativeVolumeFrame&);
|
||||
|
||||
class RelativeVolumeFramePrivate;
|
||||
|
@ -24,19 +24,19 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "synchronizedlyricsframe.h"
|
||||
#include <tbytevectorlist.h>
|
||||
#include <id3v2tag.h>
|
||||
#include <tdebug.h>
|
||||
#include <tpropertymap.h>
|
||||
#include "tbytevectorlist.h"
|
||||
#include "id3v2tag.h"
|
||||
#include "tdebug.h"
|
||||
#include "tpropertymap.h"
|
||||
|
||||
using namespace Strawberry_TagLib::TagLib;
|
||||
using namespace ID3v2;
|
||||
|
||||
class SynchronizedLyricsFrame::SynchronizedLyricsFramePrivate {
|
||||
public:
|
||||
SynchronizedLyricsFramePrivate() : textEncoding(String::Latin1),
|
||||
timestampFormat(SynchronizedLyricsFrame::AbsoluteMilliseconds),
|
||||
type(SynchronizedLyricsFrame::Lyrics) {}
|
||||
explicit SynchronizedLyricsFramePrivate() : textEncoding(String::Latin1),
|
||||
timestampFormat(SynchronizedLyricsFrame::AbsoluteMilliseconds),
|
||||
type(SynchronizedLyricsFrame::Lyrics) {}
|
||||
String::Type textEncoding;
|
||||
ByteVector language;
|
||||
SynchronizedLyricsFrame::TimestampFormat timestampFormat;
|
||||
@ -124,7 +124,7 @@ void SynchronizedLyricsFrame::setSynchedText(
|
||||
|
||||
void SynchronizedLyricsFrame::parseFields(const ByteVector &data) {
|
||||
|
||||
const int end = data.size();
|
||||
const size_t end = data.size();
|
||||
if (end < 7) {
|
||||
debug("A synchronized lyrics frame must contain at least 7 bytes.");
|
||||
return;
|
||||
@ -135,9 +135,9 @@ void SynchronizedLyricsFrame::parseFields(const ByteVector &data) {
|
||||
d->timestampFormat = TimestampFormat(data[4]);
|
||||
d->type = Type(data[5]);
|
||||
|
||||
int pos = 6;
|
||||
size_t pos = 6;
|
||||
|
||||
d->description = readStringField(data, d->textEncoding, &pos);
|
||||
d->description = readStringField(data, d->textEncoding, pos);
|
||||
if (pos == 6)
|
||||
return;
|
||||
|
||||
@ -150,7 +150,7 @@ void SynchronizedLyricsFrame::parseFields(const ByteVector &data) {
|
||||
*/
|
||||
String::Type encWithEndianness = d->textEncoding;
|
||||
if (d->textEncoding == String::UTF16) {
|
||||
unsigned short bom = data.toUShort(6, true);
|
||||
unsigned short bom = data.toUInt16BE(6);
|
||||
if (bom == 0xfffe) {
|
||||
encWithEndianness = String::UTF16LE;
|
||||
}
|
||||
@ -164,16 +164,16 @@ void SynchronizedLyricsFrame::parseFields(const ByteVector &data) {
|
||||
String::Type enc = d->textEncoding;
|
||||
// If a UTF16 string has no BOM, use the encoding found above.
|
||||
if (enc == String::UTF16 && pos + 1 < end) {
|
||||
unsigned short bom = data.toUShort(pos, true);
|
||||
unsigned short bom = data.toUInt16BE(pos);
|
||||
if (bom != 0xfffe && bom != 0xfeff) {
|
||||
enc = encWithEndianness;
|
||||
}
|
||||
}
|
||||
String text = readStringField(data, enc, &pos);
|
||||
String text = readStringField(data, enc, pos);
|
||||
if (pos + 4 > end)
|
||||
return;
|
||||
|
||||
unsigned int time = data.toUInt(pos, true);
|
||||
unsigned int time = data.toUInt32BE(pos);
|
||||
pos += 4;
|
||||
|
||||
d->synchedText.append(SynchedText(time, text));
|
||||
@ -206,7 +206,7 @@ ByteVector SynchronizedLyricsFrame::renderFields() const {
|
||||
const SynchedText &entry = *it;
|
||||
v.append(entry.text.data(encoding));
|
||||
v.append(textDelimiter(encoding));
|
||||
v.append(ByteVector::fromUInt(entry.time));
|
||||
v.append(ByteVector::fromUInt32BE(entry.time));
|
||||
}
|
||||
|
||||
return v;
|
||||
|
@ -106,14 +106,14 @@ class TAGLIB_EXPORT SynchronizedLyricsFrame : public Frame {
|
||||
/*!
|
||||
* Destroys this SynchronizedLyricsFrame instance.
|
||||
*/
|
||||
virtual ~SynchronizedLyricsFrame();
|
||||
~SynchronizedLyricsFrame() override;
|
||||
|
||||
/*!
|
||||
* Returns the description of this synchronized lyrics frame.
|
||||
*
|
||||
* \see description()
|
||||
*/
|
||||
virtual String toString() const;
|
||||
String toString() const override;
|
||||
|
||||
/*!
|
||||
* Returns the text encoding that will be used in rendering this frame.
|
||||
@ -205,15 +205,15 @@ class TAGLIB_EXPORT SynchronizedLyricsFrame : public Frame {
|
||||
protected:
|
||||
// Reimplementations.
|
||||
|
||||
virtual void parseFields(const ByteVector &data);
|
||||
virtual ByteVector renderFields() const;
|
||||
void parseFields(const ByteVector &data) override;
|
||||
ByteVector renderFields() const override;
|
||||
|
||||
private:
|
||||
/*!
|
||||
* The constructor used by the FrameFactory.
|
||||
*/
|
||||
explicit SynchronizedLyricsFrame(const ByteVector &data, Header *h);
|
||||
explicit SynchronizedLyricsFrame(const SynchronizedLyricsFrame&);
|
||||
SynchronizedLyricsFrame(const SynchronizedLyricsFrame&);
|
||||
SynchronizedLyricsFrame &operator=(const SynchronizedLyricsFrame&);
|
||||
|
||||
class SynchronizedLyricsFramePrivate;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user