mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
NowPlaying.dll: Updated TagLib to 1.7.2
This commit is contained in:
parent
bf82f0d4c7
commit
04e6446531
@ -24,7 +24,7 @@
|
|||||||
* http://www.mozilla.org/MPL/ *
|
* http://www.mozilla.org/MPL/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <ostream>
|
#include <iostream>
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
|
|
||||||
#include <tstring.h>
|
#include <tstring.h>
|
||||||
|
@ -193,7 +193,7 @@ void APE::Properties::analyzeCurrent()
|
|||||||
uint blocksPerFrame = header.mid(4, 4).toUInt(false);
|
uint blocksPerFrame = header.mid(4, 4).toUInt(false);
|
||||||
uint finalFrameBlocks = header.mid(8, 4).toUInt(false);
|
uint finalFrameBlocks = header.mid(8, 4).toUInt(false);
|
||||||
uint totalBlocks = totalFrames > 0 ? (totalFrames - 1) * blocksPerFrame + finalFrameBlocks : 0;
|
uint totalBlocks = totalFrames > 0 ? (totalFrames - 1) * blocksPerFrame + finalFrameBlocks : 0;
|
||||||
d->length = totalBlocks / d->sampleRate;
|
d->length = d->sampleRate > 0 ? totalBlocks / d->sampleRate : 0;
|
||||||
d->bitrate = d->length > 0 ? ((d->streamLength * 8L) / d->length) / 1000 : 0;
|
d->bitrate = d->length > 0 ? ((d->streamLength * 8L) / d->length) / 1000 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,7 +327,16 @@ void ASF::File::HeaderExtensionObject::parse(ASF::File *file, uint /*size*/)
|
|||||||
long long dataPos = 0;
|
long long dataPos = 0;
|
||||||
while(dataPos < dataSize) {
|
while(dataPos < dataSize) {
|
||||||
ByteVector guid = file->readBlock(16);
|
ByteVector guid = file->readBlock(16);
|
||||||
long long size = file->readQWORD();
|
if(guid.size() != 16) {
|
||||||
|
file->setValid(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
bool ok;
|
||||||
|
long long size = file->readQWORD(&ok);
|
||||||
|
if(!ok) {
|
||||||
|
file->setValid(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
BaseObject *obj;
|
BaseObject *obj;
|
||||||
if(guid == metadataGuid) {
|
if(guid == metadataGuid) {
|
||||||
obj = new MetadataObject();
|
obj = new MetadataObject();
|
||||||
@ -397,19 +406,37 @@ void ASF::File::read(bool /*readProperties*/, Properties::ReadStyle /*properties
|
|||||||
ByteVector guid = readBlock(16);
|
ByteVector guid = readBlock(16);
|
||||||
if(guid != headerGuid) {
|
if(guid != headerGuid) {
|
||||||
debug("ASF: Not an ASF file.");
|
debug("ASF: Not an ASF file.");
|
||||||
|
setValid(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->tag = new ASF::Tag();
|
d->tag = new ASF::Tag();
|
||||||
d->properties = new ASF::Properties();
|
d->properties = new ASF::Properties();
|
||||||
|
|
||||||
d->size = readQWORD();
|
bool ok;
|
||||||
int numObjects = readDWORD();
|
d->size = readQWORD(&ok);
|
||||||
|
if(!ok) {
|
||||||
|
setValid(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int numObjects = readDWORD(&ok);
|
||||||
|
if(!ok) {
|
||||||
|
setValid(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
seek(2, Current);
|
seek(2, Current);
|
||||||
|
|
||||||
for(int i = 0; i < numObjects; i++) {
|
for(int i = 0; i < numObjects; i++) {
|
||||||
ByteVector guid = readBlock(16);
|
ByteVector guid = readBlock(16);
|
||||||
long size = (long)readQWORD();
|
if(guid.size() != 16) {
|
||||||
|
setValid(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
long size = (long)readQWORD(&ok);
|
||||||
|
if(!ok) {
|
||||||
|
setValid(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
BaseObject *obj;
|
BaseObject *obj;
|
||||||
if(guid == filePropertiesGuid) {
|
if(guid == filePropertiesGuid) {
|
||||||
obj = new FilePropertiesObject();
|
obj = new FilePropertiesObject();
|
||||||
@ -437,7 +464,12 @@ void ASF::File::read(bool /*readProperties*/, Properties::ReadStyle /*properties
|
|||||||
bool ASF::File::save()
|
bool ASF::File::save()
|
||||||
{
|
{
|
||||||
if(readOnly()) {
|
if(readOnly()) {
|
||||||
debug("ASF: File is read-only.");
|
debug("ASF::File::save() -- File is read only.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isValid()) {
|
||||||
|
debug("ASF::File::save() -- Trying to save invalid file.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -499,27 +531,47 @@ bool ASF::File::save()
|
|||||||
// protected members
|
// protected members
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int ASF::File::readBYTE()
|
int ASF::File::readBYTE(bool *ok)
|
||||||
{
|
{
|
||||||
ByteVector v = readBlock(1);
|
ByteVector v = readBlock(1);
|
||||||
|
if(v.size() != 1) {
|
||||||
|
if(ok) *ok = false;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if(ok) *ok = true;
|
||||||
return v[0];
|
return v[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
int ASF::File::readWORD()
|
int ASF::File::readWORD(bool *ok)
|
||||||
{
|
{
|
||||||
ByteVector v = readBlock(2);
|
ByteVector v = readBlock(2);
|
||||||
|
if(v.size() != 2) {
|
||||||
|
if(ok) *ok = false;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if(ok) *ok = true;
|
||||||
return v.toUShort(false);
|
return v.toUShort(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int ASF::File::readDWORD()
|
unsigned int ASF::File::readDWORD(bool *ok)
|
||||||
{
|
{
|
||||||
ByteVector v = readBlock(4);
|
ByteVector v = readBlock(4);
|
||||||
|
if(v.size() != 4) {
|
||||||
|
if(ok) *ok = false;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if(ok) *ok = true;
|
||||||
return v.toUInt(false);
|
return v.toUInt(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
long long ASF::File::readQWORD()
|
long long ASF::File::readQWORD(bool *ok)
|
||||||
{
|
{
|
||||||
ByteVector v = readBlock(8);
|
ByteVector v = readBlock(8);
|
||||||
|
if(v.size() != 8) {
|
||||||
|
if(ok) *ok = false;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if(ok) *ok = true;
|
||||||
return v.toLongLong(false);
|
return v.toLongLong(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,10 +88,10 @@ namespace TagLib {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
int readBYTE();
|
int readBYTE(bool *ok = 0);
|
||||||
int readWORD();
|
int readWORD(bool *ok = 0);
|
||||||
unsigned int readDWORD();
|
unsigned int readDWORD(bool *ok = 0);
|
||||||
long long readQWORD();
|
long long readQWORD(bool *ok = 0);
|
||||||
static ByteVector renderString(const String &str, bool includeLength = false);
|
static ByteVector renderString(const String &str, bool includeLength = false);
|
||||||
String readString(int len);
|
String readString(int len);
|
||||||
void read(bool readProperties, Properties::ReadStyle propertiesStyle);
|
void read(bool readProperties, Properties::ReadStyle propertiesStyle);
|
||||||
|
@ -149,7 +149,7 @@ bool FLAC::File::save()
|
|||||||
|
|
||||||
// Create new vorbis comments
|
// Create new vorbis comments
|
||||||
|
|
||||||
Tag::duplicate(&d->tag, xiphComment(true), true);
|
Tag::duplicate(&d->tag, xiphComment(true), false);
|
||||||
|
|
||||||
d->xiphCommentData = xiphComment()->render(false);
|
d->xiphCommentData = xiphComment()->render(false);
|
||||||
|
|
||||||
@ -161,10 +161,12 @@ bool FLAC::File::save()
|
|||||||
MetadataBlock *block = d->blocks[i];
|
MetadataBlock *block = d->blocks[i];
|
||||||
if(block->code() == MetadataBlock::VorbisComment) {
|
if(block->code() == MetadataBlock::VorbisComment) {
|
||||||
// Set the new Vorbis Comment block
|
// Set the new Vorbis Comment block
|
||||||
|
delete block;
|
||||||
block = new UnknownMetadataBlock(MetadataBlock::VorbisComment, d->xiphCommentData);
|
block = new UnknownMetadataBlock(MetadataBlock::VorbisComment, d->xiphCommentData);
|
||||||
foundVorbisCommentBlock = true;
|
foundVorbisCommentBlock = true;
|
||||||
}
|
}
|
||||||
if(block->code() == MetadataBlock::Padding) {
|
if(block->code() == MetadataBlock::Padding) {
|
||||||
|
delete block;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
newBlocks.append(block);
|
newBlocks.append(block);
|
||||||
|
@ -91,15 +91,24 @@ MP4::Properties::Properties(File *file, MP4::Atoms *atoms, ReadStyle style)
|
|||||||
|
|
||||||
file->seek(mdhd->offset);
|
file->seek(mdhd->offset);
|
||||||
data = file->readBlock(mdhd->length);
|
data = file->readBlock(mdhd->length);
|
||||||
if(data[8] == 0) {
|
uint version = data[8];
|
||||||
unsigned int unit = data.mid(20, 4).toUInt();
|
if(version == 1) {
|
||||||
unsigned int length = data.mid(24, 4).toUInt();
|
if (data.size() < 36 + 8) {
|
||||||
d->length = length / unit;
|
debug("MP4: Atom 'trak.mdia.mdhd' is smaller than expected");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
long long unit = data.mid(28, 8).toLongLong();
|
long long unit = data.mid(28, 8).toLongLong();
|
||||||
long long length = data.mid(36, 8).toLongLong();
|
long long length = data.mid(36, 8).toLongLong();
|
||||||
d->length = int(length / unit);
|
d->length = unit ? int(length / unit) : 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (data.size() < 24 + 4) {
|
||||||
|
debug("MP4: Atom 'trak.mdia.mdhd' is smaller than expected");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
unsigned int unit = data.mid(20, 4).toUInt();
|
||||||
|
unsigned int length = data.mid(24, 4).toUInt();
|
||||||
|
d->length = unit ? length / unit : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
MP4::Atom *atom = trak->find("mdia", "minf", "stbl", "stsd");
|
MP4::Atom *atom = trak->find("mdia", "minf", "stbl", "stsd");
|
||||||
|
@ -51,8 +51,7 @@ public:
|
|||||||
static const StringHandler *stringHandler;
|
static const StringHandler *stringHandler;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const StringHandler defaultStringHandler;
|
const ID3v1::StringHandler *ID3v1::Tag::TagPrivate::stringHandler = new StringHandler;
|
||||||
const ID3v1::StringHandler *ID3v1::Tag::TagPrivate::stringHandler = &defaultStringHandler;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// StringHandler implementation
|
// StringHandler implementation
|
||||||
@ -190,9 +189,7 @@ void ID3v1::Tag::setTrack(uint i)
|
|||||||
|
|
||||||
void ID3v1::Tag::setStringHandler(const StringHandler *handler)
|
void ID3v1::Tag::setStringHandler(const StringHandler *handler)
|
||||||
{
|
{
|
||||||
if(TagPrivate::stringHandler != &defaultStringHandler)
|
|
||||||
delete TagPrivate::stringHandler;
|
delete TagPrivate::stringHandler;
|
||||||
|
|
||||||
TagPrivate::stringHandler = handler;
|
TagPrivate::stringHandler = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,8 +73,9 @@ FrameFactory *FrameFactory::factory = 0;
|
|||||||
|
|
||||||
FrameFactory *FrameFactory::instance()
|
FrameFactory *FrameFactory::instance()
|
||||||
{
|
{
|
||||||
static FrameFactory factory;
|
if(!factory)
|
||||||
return &factory;
|
factory = new FrameFactory;
|
||||||
|
return factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
Frame *FrameFactory::createFrame(const ByteVector &data, bool synchSafeInts) const
|
Frame *FrameFactory::createFrame(const ByteVector &data, bool synchSafeInts) const
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
* http://www.mozilla.org/MPL/ *
|
* http://www.mozilla.org/MPL/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <ostream>
|
#include <iostream>
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
|
|
||||||
#include <tstring.h>
|
#include <tstring.h>
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
* http://www.mozilla.org/MPL/ *
|
* http://www.mozilla.org/MPL/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <ostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "id3v2synchdata.h"
|
#include "id3v2synchdata.h"
|
||||||
|
|
||||||
|
@ -287,7 +287,7 @@ void Ogg::XiphComment::parse(const ByteVector &data)
|
|||||||
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
int vendorLength = data.mid(0, 4).toUInt(false);
|
uint vendorLength = data.mid(0, 4).toUInt(false);
|
||||||
pos += 4;
|
pos += 4;
|
||||||
|
|
||||||
d->vendorID = String(data.mid(pos, vendorLength), String::UTF8);
|
d->vendorID = String(data.mid(pos, vendorLength), String::UTF8);
|
||||||
@ -295,21 +295,31 @@ void Ogg::XiphComment::parse(const ByteVector &data)
|
|||||||
|
|
||||||
// Next the number of fields in the comment vector.
|
// Next the number of fields in the comment vector.
|
||||||
|
|
||||||
int commentFields = data.mid(pos, 4).toUInt(false);
|
uint commentFields = data.mid(pos, 4).toUInt(false);
|
||||||
pos += 4;
|
pos += 4;
|
||||||
|
|
||||||
for(int i = 0; i < commentFields; i++) {
|
if(commentFields > (data.size() - 8) / 4) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(uint i = 0; i < commentFields; i++) {
|
||||||
|
|
||||||
// Each comment field is in the format "KEY=value" in a UTF8 string and has
|
// Each comment field is in the format "KEY=value" in a UTF8 string and has
|
||||||
// 4 bytes before the text starts that gives the length.
|
// 4 bytes before the text starts that gives the length.
|
||||||
|
|
||||||
int commentLength = data.mid(pos, 4).toUInt(false);
|
uint commentLength = data.mid(pos, 4).toUInt(false);
|
||||||
pos += 4;
|
pos += 4;
|
||||||
|
|
||||||
String comment = String(data.mid(pos, commentLength), String::UTF8);
|
String comment = String(data.mid(pos, commentLength), String::UTF8);
|
||||||
pos += commentLength;
|
pos += commentLength;
|
||||||
|
if(pos > data.size()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
int commentSeparatorPosition = comment.find("=");
|
int commentSeparatorPosition = comment.find("=");
|
||||||
|
if(commentSeparatorPosition == -1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
String key = comment.substr(0, commentSeparatorPosition);
|
String key = comment.substr(0, commentSeparatorPosition);
|
||||||
String value = comment.substr(commentSeparatorPosition + 1);
|
String value = comment.substr(commentSeparatorPosition + 1);
|
||||||
|
@ -87,6 +87,11 @@ bool RIFF::AIFF::File::save()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!isValid()) {
|
||||||
|
debug("RIFF::AIFF::File::save() -- Trying to save invalid file.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
setChunkData(d->tagChunkID, d->tag->render());
|
setChunkData(d->tagChunkID, d->tag->render());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -149,5 +149,5 @@ void RIFF::AIFF::Properties::read(const ByteVector &data)
|
|||||||
double sampleRate = ConvertFromIeeeExtended(reinterpret_cast<unsigned char *>(data.mid(8, 10).data()));
|
double sampleRate = ConvertFromIeeeExtended(reinterpret_cast<unsigned char *>(data.mid(8, 10).data()));
|
||||||
d->sampleRate = sampleRate;
|
d->sampleRate = sampleRate;
|
||||||
d->bitrate = (sampleRate * d->sampleWidth * d->channels) / 1000.0;
|
d->bitrate = (sampleRate * d->sampleWidth * d->channels) / 1000.0;
|
||||||
d->length = sampleFrames / d->sampleRate;
|
d->length = d->sampleRate > 0 ? sampleFrames / d->sampleRate : 0;
|
||||||
}
|
}
|
||||||
|
@ -194,6 +194,19 @@ void RIFF::File::setChunkData(const ByteVector &name, const ByteVector &data)
|
|||||||
// private members
|
// private members
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
static bool isValidChunkID(const ByteVector &name)
|
||||||
|
{
|
||||||
|
if(name.size() != 4) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for(int i = 0; i < 4; i++) {
|
||||||
|
if(name[i] < 32 || name[i] > 127) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void RIFF::File::read()
|
void RIFF::File::read()
|
||||||
{
|
{
|
||||||
bool bigEndian = (d->endianness == BigEndian);
|
bool bigEndian = (d->endianness == BigEndian);
|
||||||
@ -207,8 +220,15 @@ void RIFF::File::read()
|
|||||||
ByteVector chunkName = readBlock(4);
|
ByteVector chunkName = readBlock(4);
|
||||||
uint chunkSize = readBlock(4).toUInt(bigEndian);
|
uint chunkSize = readBlock(4).toUInt(bigEndian);
|
||||||
|
|
||||||
|
if(!isValidChunkID(chunkName)) {
|
||||||
|
debug("RIFF::File::read() -- Chunk '" + chunkName + "' has invalid ID");
|
||||||
|
setValid(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if(tell() + chunkSize > uint(length())) {
|
if(tell() + chunkSize > uint(length())) {
|
||||||
// something wrong
|
debug("RIFF::File::read() -- Chunk '" + chunkName + "' has invalid size (larger than the file size)");
|
||||||
|
setValid(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,6 +87,11 @@ bool RIFF::WAV::File::save()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!isValid()) {
|
||||||
|
debug("RIFF::WAV::File::save() -- Trying to save invalid file.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
setChunkData(d->tagChunkID, d->tag->render());
|
setChunkData(d->tagChunkID, d->tag->render());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
* *
|
* *
|
||||||
* You should have received a copy of the GNU Lesser General Public *
|
* You should have received a copy of the GNU Lesser General Public *
|
||||||
* License along with this library; if not, write to the Free Software *
|
* License along with this library; if not, write to the Free Software *
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
* USA *
|
* 02110-1301 USA *
|
||||||
* *
|
* *
|
||||||
* Alternatively, this file is available under the Mozilla Public *
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
* License Version 1.1. You may obtain a copy of the License at *
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
@ -26,18 +26,21 @@
|
|||||||
#ifndef TAGLIB_EXPORT_H
|
#ifndef TAGLIB_EXPORT_H
|
||||||
#define TAGLIB_EXPORT_H
|
#define TAGLIB_EXPORT_H
|
||||||
|
|
||||||
|
#define TAGLIB_STATIC
|
||||||
|
|
||||||
/*
|
#if defined(TAGLIB_STATIC)
|
||||||
#if (defined(_WIN32) || defined(_WIN64)) && (!defined(MAKE_TAGLIB_STATIC))
|
#define TAGLIB_EXPORT
|
||||||
#ifdef MAKE_TAGLIB_LIB
|
#elif (defined(_WIN32) || defined(_WIN64))
|
||||||
#define TAGLIB_EXPORT __declspec(dllexport)
|
#ifdef MAKE_TAGLIB_LIB
|
||||||
#else
|
#define TAGLIB_EXPORT __declspec(dllexport)
|
||||||
#define TAGLIB_EXPORT __declspec(dllimport)
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
*/
|
#define TAGLIB_EXPORT __declspec(dllimport)
|
||||||
#define TAGLIB_EXPORT
|
#endif
|
||||||
//#endif
|
#elif defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 1)
|
||||||
|
#define TAGLIB_EXPORT __attribute__ ((visibility("default")))
|
||||||
|
#else
|
||||||
|
#define TAGLIB_EXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef TAGLIB_NO_CONFIG
|
#ifndef TAGLIB_NO_CONFIG
|
||||||
#include "taglib_config.h"
|
#include "taglib_config.h"
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
* http://www.mozilla.org/MPL/ *
|
* http://www.mozilla.org/MPL/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <ostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <tstring.h>
|
#include <tstring.h>
|
||||||
#include <tdebug.h>
|
#include <tdebug.h>
|
||||||
@ -363,7 +363,7 @@ ByteVector ByteVector::mid(uint index, uint length) const
|
|||||||
|
|
||||||
ConstIterator endIt;
|
ConstIterator endIt;
|
||||||
|
|
||||||
if(length < 0xffffffff && length + index < size())
|
if(length < size() - index)
|
||||||
endIt = d->data.begin() + index + length;
|
endIt = d->data.begin() + index + length;
|
||||||
else
|
else
|
||||||
endIt = d->data.end();
|
endIt = d->data.end();
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#include "taglib_export.h"
|
#include "taglib_export.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <ostream>
|
#include <iostream>
|
||||||
|
|
||||||
namespace TagLib {
|
namespace TagLib {
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "unicode.h"
|
#include "unicode.h"
|
||||||
#include "tdebug.h"
|
#include "tdebug.h"
|
||||||
|
|
||||||
#include <ostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include "tbytevector.h"
|
#include "tbytevector.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <ostream>
|
#include <iostream>
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \relates TagLib::String
|
* \relates TagLib::String
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include "tbytevectorlist.h"
|
#include "tbytevectorlist.h"
|
||||||
#include "taglib_export.h"
|
#include "taglib_export.h"
|
||||||
|
|
||||||
#include <ostream>
|
#include <iostream>
|
||||||
|
|
||||||
namespace TagLib {
|
namespace TagLib {
|
||||||
|
|
||||||
|
@ -118,7 +118,13 @@ void TrueAudio::Properties::read()
|
|||||||
int pos = 3;
|
int pos = 3;
|
||||||
|
|
||||||
d->version = d->data[pos] - '0';
|
d->version = d->data[pos] - '0';
|
||||||
pos += 1 + 2;
|
pos += 1;
|
||||||
|
|
||||||
|
// According to http://en.true-audio.com/TTA_Lossless_Audio_Codec_-_Format_Description
|
||||||
|
// TTA2 headers are in development, and have a different format
|
||||||
|
if(1 == d->version) {
|
||||||
|
// Skip the audio format
|
||||||
|
pos += 2;
|
||||||
|
|
||||||
d->channels = d->data.mid(pos, 2).toShort(false);
|
d->channels = d->data.mid(pos, 2).toShort(false);
|
||||||
pos += 2;
|
pos += 2;
|
||||||
@ -129,8 +135,9 @@ void TrueAudio::Properties::read()
|
|||||||
d->sampleRate = d->data.mid(pos, 4).toUInt(false);
|
d->sampleRate = d->data.mid(pos, 4).toUInt(false);
|
||||||
pos += 4;
|
pos += 4;
|
||||||
|
|
||||||
unsigned long samples = d->data.mid(pos, 4).toUInt(false);
|
uint sampleFrames = d->data.mid(pos, 4).toUInt(false);
|
||||||
d->length = samples / d->sampleRate;
|
d->length = d->sampleRate > 0 ? sampleFrames / d->sampleRate : 0;
|
||||||
|
|
||||||
d->bitrate = d->length > 0 ? ((d->streamLength * 8L) / d->length) / 1000 : 0;
|
d->bitrate = d->length > 0 ? ((d->streamLength * 8L) / d->length) / 1000 : 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user