Bump 3rd party taglib to 1.9.1

This commit is contained in:
Arnaud Bienner 2013-12-17 19:38:05 +01:00
parent 565c2cc921
commit 05b76f1d81
18 changed files with 213 additions and 91 deletions

View File

@ -413,18 +413,9 @@ void FLAC::File::scan()
d->blocks.append(new UnknownMetadataBlock(blockType, d->streamInfoData));
nextBlockOffset += length + 4;
int blockCount = 0;
// Search through the remaining metadata
while(!isLastBlock) {
if (++blockCount > 1024) {
debug("FLAC::File::scan() -- FLAC stream has more than 1024 metadata "
"blocks, probably corrupt.");
setValid(false);
return;
}
header = readBlock(4);
blockType = header[0] & 0x7f;
isLastBlock = (header[0] & 0x80) != 0;

View File

@ -34,7 +34,7 @@ using namespace TagLib;
class MP4::Properties::PropertiesPrivate
{
public:
PropertiesPrivate() : length(0), bitrate(0), sampleRate(0), channels(0), bitsPerSample(0), encrypted(false) {}
PropertiesPrivate() : length(0), bitrate(0), sampleRate(0), channels(0), bitsPerSample(0), encrypted(false), codec(MP4::Properties::Unknown) {}
int length;
int bitrate;
@ -42,6 +42,7 @@ public:
int channels;
int bitsPerSample;
bool encrypted;
Codec codec;
};
MP4::Properties::Properties(File *file, MP4::Atoms *atoms, ReadStyle style)
@ -114,6 +115,7 @@ MP4::Properties::Properties(File *file, MP4::Atoms *atoms, ReadStyle style)
file->seek(atom->offset);
data = file->readBlock(atom->length);
if(data.mid(20, 4) == "mp4a") {
d->codec = AAC;
d->channels = data.toShort(40U);
d->bitsPerSample = data.toShort(42U);
d->sampleRate = data.toUInt(46U);
@ -135,10 +137,11 @@ MP4::Properties::Properties(File *file, MP4::Atoms *atoms, ReadStyle style)
}
else if (data.mid(20, 4) == "alac") {
if (atom->length == 88 && data.mid(56, 4) == "alac") {
d->codec = ALAC;
d->bitsPerSample = data.at(69);
d->channels = data.at(73);
d->bitrate = data.toUInt(80U) / 1000;
d->sampleRate = data.toUInt(84U);
d->channels = data.at(73);
d->bitrate = data.toUInt(80U) / 1000;
d->sampleRate = data.toUInt(84U);
}
}
@ -189,3 +192,8 @@ MP4::Properties::isEncrypted() const
return d->encrypted;
}
MP4::Properties::Codec MP4::Properties::codec() const
{
return d->codec;
}

View File

@ -40,6 +40,12 @@ namespace TagLib {
class TAGLIB_EXPORT Properties : public AudioProperties
{
public:
enum Codec {
Unknown = 0,
AAC,
ALAC
};
Properties(File *file, Atoms *atoms, ReadStyle style = Average);
virtual ~Properties();
@ -50,6 +56,9 @@ namespace TagLib {
virtual int bitsPerSample() const;
bool isEncrypted() const;
//! Audio codec used in the MP4 file
Codec codec() const;
private:
class PropertiesPrivate;
PropertiesPrivate *d;

View File

@ -392,7 +392,7 @@ static const char *frameTranslation[][2] = {
//{ "USLT", "LYRICS" }, handled specially
};
static const TagLib::uint txxxFrameTranslationSize = 7;
static const TagLib::uint txxxFrameTranslationSize = 8;
static const char *txxxFrameTranslation[][2] = {
{ "MusicBrainz Album Id", "MUSICBRAINZ_ALBUMID" },
{ "MusicBrainz Artist Id", "MUSICBRAINZ_ARTISTID" },

View File

@ -28,6 +28,7 @@
#include <tstring.h>
#include "rifffile.h"
#include <algorithm>
#include <vector>
using namespace TagLib;
@ -272,7 +273,7 @@ void RIFF::File::read()
break;
}
if(tell() + chunkSize > uint(length())) {
if(static_cast<ulonglong>(tell()) + chunkSize > static_cast<ulonglong>(length())) {
debug("RIFF::File::read() -- Chunk '" + chunkName + "' has invalid size (larger than the file size)");
setValid(false);
break;

View File

@ -185,6 +185,11 @@ bool RIFF::Info::Tag::isEmpty() const
return d->fieldListMap.isEmpty();
}
FieldListMap RIFF::Info::Tag::fieldListMap() const
{
return d->fieldListMap;
}
String RIFF::Info::Tag::fieldText(const ByteVector &id) const
{
if(d->fieldListMap.contains(id))

View File

@ -120,6 +120,18 @@ namespace TagLib {
virtual bool isEmpty() const;
/*!
* Returns a copy of the internal fields of the tag. The returned map directly
* reflects the contents of the "INFO" chunk.
*
* \note Modifying this map does not affect the tag's internal data.
* Use setFieldText() and removeField() instead.
*
* \see setFieldText()
* \see removeField()
*/
FieldListMap fieldListMap() const;
/*
* Gets the value of the field with the ID \a id.
*/

View File

@ -29,8 +29,8 @@
#include "taglib_config.h"
#define TAGLIB_MAJOR_VERSION 1
#define TAGLIB_MINOR_VERSION 8
#define TAGLIB_PATCH_VERSION 0
#define TAGLIB_MINOR_VERSION 9
#define TAGLIB_PATCH_VERSION 1
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 1))
#define TAGLIB_IGNORE_MISSING_DESTRUCTOR _Pragma("GCC diagnostic ignored \"-Wnon-virtual-dtor\"")

View File

@ -27,6 +27,7 @@
#include <config.h>
#endif
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstring>
@ -208,6 +209,9 @@ T toNumber(const ByteVector &v, size_t offset, size_t length, bool mostSignifica
template <class T>
T toNumber(const ByteVector &v, size_t offset, bool mostSignificantByteFirst)
{
static const bool isBigEndian = (Utils::SystemByteOrder == Utils::BigEndian);
const bool swap = (mostSignificantByteFirst != isBigEndian);
if(offset + sizeof(T) > v.size())
return toNumber<T>(v, offset, v.size() - offset, mostSignificantByteFirst);
@ -215,13 +219,8 @@ T toNumber(const ByteVector &v, size_t offset, bool mostSignificantByteFirst)
T tmp;
::memcpy(&tmp, v.data() + offset, sizeof(T));
#if SYSTEM_BYTEORDER == 1
const bool swap = mostSignificantByteFirst;
#else
const bool swap = !mostSignificantByteFirst;
#endif
if(swap)
return byteSwap(tmp);
return Utils::byteSwap(tmp);
else
return tmp;
}
@ -229,17 +228,13 @@ T toNumber(const ByteVector &v, size_t offset, bool mostSignificantByteFirst)
template <class T>
ByteVector fromNumber(T value, bool mostSignificantByteFirst)
{
const size_t size = sizeof(T);
static const bool isBigEndian = (Utils::SystemByteOrder == Utils::BigEndian);
const bool swap = (mostSignificantByteFirst != isBigEndian);
#if SYSTEM_BYTEORDER == 1
const bool swap = mostSignificantByteFirst;
#else
const bool swap = !mostSignificantByteFirst;
#endif
if(swap)
value = byteSwap(value);
if(swap)
value = Utils::byteSwap(value);
return ByteVector(reinterpret_cast<const char *>(&value), size);
return ByteVector(reinterpret_cast<const char *>(&value), sizeof(T));
}
class DataPrivate : public RefCounter

View File

@ -39,7 +39,8 @@ namespace TagLib {
// A base for the generic and specialized private class types. New
// non-templatized members should be added here.
class ListPrivateBase : public RefCounter
// BIC change to RefCounter
class ListPrivateBase : public RefCounterOld
{
public:
ListPrivateBase() : autoDelete(false) {}

View File

@ -31,17 +31,18 @@ namespace TagLib {
// public members
////////////////////////////////////////////////////////////////////////////////
// BIC change to RefCounter
template <class Key, class T>
template <class KeyP, class TP>
class Map<Key, T>::MapPrivate : public RefCounter
class Map<Key, T>::MapPrivate : public RefCounterOld
{
public:
MapPrivate() : RefCounter() {}
MapPrivate() : RefCounterOld() {}
#ifdef WANT_CLASS_INSTANTIATION_OF_MAP
MapPrivate(const std::map<class KeyP, class TP>& m) : RefCounter(), map(m) {}
MapPrivate(const std::map<class KeyP, class TP>& m) : RefCounterOld(), map(m) {}
std::map<class KeyP, class TP> map;
#else
MapPrivate(const std::map<KeyP, TP>& m) : RefCounter(), map(m) {}
MapPrivate(const std::map<KeyP, TP>& m) : RefCounterOld(), map(m) {}
std::map<KeyP, TP> map;
#endif
};

View File

@ -29,6 +29,23 @@
#include "taglib_export.h"
#include "taglib.h"
#ifdef __APPLE__
# include <libkern/OSAtomic.h>
# define TAGLIB_ATOMIC_MAC
#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
# define NOMINMAX
# include <windows.h>
# define TAGLIB_ATOMIC_WIN
#elif defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 401) \
&& (defined(__i386__) || defined(__i486__) || defined(__i586__) || \
defined(__i686__) || defined(__x86_64) || defined(__ia64)) \
&& !defined(__INTEL_COMPILER)
# define TAGLIB_ATOMIC_GCC
#elif defined(__ia64) && defined(__INTEL_COMPILER)
# include <ia64intrin.h>
# define TAGLIB_ATOMIC_GCC
#endif
#ifndef DO_NOT_DOCUMENT // Tell Doxygen to skip this class.
/*!
* \internal
@ -38,6 +55,7 @@
*/
namespace TagLib
{
class TAGLIB_EXPORT RefCounter
{
public:
@ -52,7 +70,42 @@ namespace TagLib
class RefCounterPrivate;
RefCounterPrivate *d;
};
// BIC this old class is needed by tlist.tcc and tmap.tcc
class RefCounterOld
{
public:
RefCounterOld() : refCount(1) {}
#ifdef TAGLIB_ATOMIC_MAC
void ref() { OSAtomicIncrement32Barrier(const_cast<int32_t*>(&refCount)); }
bool deref() { return ! OSAtomicDecrement32Barrier(const_cast<int32_t*>(&refCount)); }
int32_t count() { return refCount; }
private:
volatile int32_t refCount;
#elif defined(TAGLIB_ATOMIC_WIN)
void ref() { InterlockedIncrement(&refCount); }
bool deref() { return ! InterlockedDecrement(&refCount); }
long count() { return refCount; }
private:
volatile long refCount;
#elif defined(TAGLIB_ATOMIC_GCC)
void ref() { __sync_add_and_fetch(&refCount, 1); }
bool deref() { return ! __sync_sub_and_fetch(&refCount, 1); }
int count() { return refCount; }
private:
volatile int refCount;
#else
void ref() { refCount++; }
bool deref() { return ! --refCount; }
int count() { return refCount; }
private:
uint refCount;
#endif
};
}
#endif // DO_NOT_DOCUMENT
#endif

View File

@ -268,6 +268,9 @@ String::String(const ByteVector &v, Type t)
copyFromUTF8(v.data(), v.size());
else
copyFromUTF16(v.data(), v.size(), t);
// If we hit a null in the ByteVector, shrink the string again.
d->data.resize(::wcslen(d->data.c_str()));
}
////////////////////////////////////////////////////////////////////////////////
@ -800,7 +803,7 @@ void String::copyFromUTF16(const wchar_t *s, size_t length, Type t)
if(swap) {
for(size_t i = 0; i < length; ++i)
d->data[i] = byteSwap(static_cast<ushort>(s[i]));
d->data[i] = Utils::byteSwap(static_cast<ushort>(s[i]));
}
}
@ -839,15 +842,8 @@ void String::copyFromUTF16(const char *s, size_t length, Type t)
}
}
#if SYSTEM_BYTEORDER == 1
const String::Type String::WCharByteOrder = String::UTF16LE;
#else
const String::Type String::WCharByteOrder = String::UTF16BE;
#endif
const String::Type String::WCharByteOrder
= (Utils::SystemByteOrder == Utils::BigEndian) ? String::UTF16BE : String::UTF16LE;
}

View File

@ -46,105 +46,144 @@
namespace TagLib
{
inline ushort byteSwap(ushort x)
namespace Utils
{
inline ushort byteSwap(ushort x)
{
#if defined(HAVE_GCC_BYTESWAP_16)
return __builtin_bswap16(x);
return __builtin_bswap16(x);
#elif defined(HAVE_MSC_BYTESWAP)
return _byteswap_ushort(x);
return _byteswap_ushort(x);
#elif defined(HAVE_GLIBC_BYTESWAP)
return __bswap_16(x);
return __bswap_16(x);
#elif defined(HAVE_MAC_BYTESWAP)
return OSSwapInt16(x);
return OSSwapInt16(x);
#elif defined(HAVE_OPENBSD_BYTESWAP)
return swap16(x);
return swap16(x);
#else
return ((x >> 8) & 0xff) | ((x & 0xff) << 8);
return ((x >> 8) & 0xff) | ((x & 0xff) << 8);
#endif
}
}
inline uint byteSwap(uint x)
{
inline uint byteSwap(uint x)
{
#if defined(HAVE_GCC_BYTESWAP_32)
return __builtin_bswap32(x);
return __builtin_bswap32(x);
#elif defined(HAVE_MSC_BYTESWAP)
return _byteswap_ulong(x);
return _byteswap_ulong(x);
#elif defined(HAVE_GLIBC_BYTESWAP)
return __bswap_32(x);
return __bswap_32(x);
#elif defined(HAVE_MAC_BYTESWAP)
return OSSwapInt32(x);
return OSSwapInt32(x);
#elif defined(HAVE_OPENBSD_BYTESWAP)
return swap32(x);
return swap32(x);
#else
return ((x & 0xff000000u) >> 24)
| ((x & 0x00ff0000u) >> 8)
| ((x & 0x0000ff00u) << 8)
| ((x & 0x000000ffu) << 24);
return ((x & 0xff000000u) >> 24)
| ((x & 0x00ff0000u) >> 8)
| ((x & 0x0000ff00u) << 8)
| ((x & 0x000000ffu) << 24);
#endif
}
}
inline ulonglong byteSwap(ulonglong x)
{
inline ulonglong byteSwap(ulonglong x)
{
#if defined(HAVE_GCC_BYTESWAP_64)
return __builtin_bswap64(x);
return __builtin_bswap64(x);
#elif defined(HAVE_MSC_BYTESWAP)
return _byteswap_uint64(x);
return _byteswap_uint64(x);
#elif defined(HAVE_GLIBC_BYTESWAP)
return __bswap_64(x);
return __bswap_64(x);
#elif defined(HAVE_MAC_BYTESWAP)
return OSSwapInt64(x);
return OSSwapInt64(x);
#elif defined(HAVE_OPENBSD_BYTESWAP)
return swap64(x);
return swap64(x);
#else
return ((x & 0xff00000000000000ull) >> 56)
| ((x & 0x00ff000000000000ull) >> 40)
| ((x & 0x0000ff0000000000ull) >> 24)
| ((x & 0x000000ff00000000ull) >> 8)
| ((x & 0x00000000ff000000ull) << 8)
| ((x & 0x0000000000ff0000ull) << 24)
| ((x & 0x000000000000ff00ull) << 40)
| ((x & 0x00000000000000ffull) << 56);
return ((x & 0xff00000000000000ull) >> 56)
| ((x & 0x00ff000000000000ull) >> 40)
| ((x & 0x0000ff0000000000ull) >> 24)
| ((x & 0x000000ff00000000ull) >> 8)
| ((x & 0x00000000ff000000ull) << 8)
| ((x & 0x0000000000ff0000ull) << 24)
| ((x & 0x000000000000ff00ull) << 40)
| ((x & 0x00000000000000ffull) << 56);
#endif
}
enum ByteOrder
{
LittleEndian,
BigEndian
};
#ifdef SYSTEM_BYTEORDER
# if SYSTEM_BYTEORDER == 1
const ByteOrder SystemByteOrder = LittleEndian;
# else
const ByteOrder SystemByteOrder = BigEndian;
# endif
#else
inline ByteOrder systemByteOrder()
{
union {
int i;
char c;
} u;
u.i = 1;
if(u.c == 1)
return LittleEndian;
else
return BigEndian;
}
const ByteOrder SystemByteOrder = systemByteOrder();
#endif
}
};
}
#endif

View File

@ -106,6 +106,11 @@
bit mask & shift operations.
------------------------------------------------------------------------ */
// Workaround for when MSVC doesn't have wchar_t as a built-in type.
#if defined(_MSC_VER) && !defined(_WCHAR_T_DEFINED)
# include <wchar.h>
#endif
/* Some fundamental constants */
#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD
#define UNI_MAX_BMP (UTF32)0x0000FFFF
@ -114,10 +119,10 @@
namespace Unicode {
typedef unsigned long UTF32; /* at least 32 bits */
typedef wchar_t UTF16; /* TagLib assumes that wchar_t is sufficient for UTF-16. */
typedef unsigned long UTF32; /* at least 32 bits */
typedef wchar_t UTF16; /* TagLib assumes that wchar_t is sufficient for UTF-16. */
typedef unsigned char UTF8; /* typically 8 bits */
typedef unsigned char Boolean; /* 0 or 1 */
typedef unsigned char Boolean; /* 0 or 1 */
typedef enum {
conversionOK = 0, /* conversion successful */

View File

@ -126,8 +126,9 @@ TagLib::uint WavPack::Properties::sampleFrames() const
// private members
////////////////////////////////////////////////////////////////////////////////
static const unsigned int sample_rates[] = { 6000, 8000, 9600, 11025, 12000,
16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000, 192000 };
static const unsigned int sample_rates[] = {
6000, 8000, 9600, 11025, 12000, 16000, 22050, 24000,
32000, 44100, 48000, 64000, 88200, 96000, 192000, 0 };
#define BYTES_STORED 3
#define MONO_FLAG 4

View File

@ -75,7 +75,12 @@ namespace TagLib {
virtual int length() const;
virtual int bitrate() const;
/*!
* Returns the sample rate in Hz. 0 means unknown or custom.
*/
virtual int sampleRate() const;
virtual int channels() const;
/*!

View File

@ -101,7 +101,7 @@ if (USE_BUILTIN_TAGLIB AND
(NOT "${ENABLE_GOOGLE_DRIVE}" STREQUAL "OFF") AND
SPARSEHASH_INCLUDE_DIRS AND
TAGLIB_VERSION VERSION_LESS 1.8)
set(TAGLIB_VERSION 1.8)
set(TAGLIB_VERSION 1.9.1)
set(TAGLIB_INCLUDE_DIRS "${CMAKE_BINARY_DIR}/3rdparty/taglib/headers/taglib/;${CMAKE_BINARY_DIR}/3rdparty/taglib/headers/")
set(TAGLIB_LIBRARY_DIRS "")
set(TAGLIB_LIBRARIES tag)