mirror of
https://github.com/taglib/taglib.git
synced 2026-08-14 06:17:00 -04:00
Support large files over 2GB on Windows (#1089)
Backport of4dcf0b41c6b01f45e141https://github.com/taglib/taglib/pull/77 Tested with files larger than 2GB which have been created using sox -n -r 44100 -C 320 large.mp3 synth 58916 sine 440 channels 2 sox -n -r 44100 -C 0 large.flac synth 25459 sine 440 channels 2 sox -n -r 44100 -C 10 large.ogg synth 229806 sine 440 channels 2 sox -n -r 44100 large.wav synth 6692 sine 440 channels 2 ffmpeg -f lavfi -i "sine=frequency=440:duration=244676" -y large.m4a The only file which was readable with the tagreader example before this commit was large.ogg. The problem is that long on Windows is only 32-bit (also in LLP64 data model of 64-bit compilation target) and all the file offsets using long are too small for large files. Now long is replaced by offset_t (defined to be long long on Windows and off_t on UNIX) for such cases and some unsigned long are now size_t, which has the correct size even on Windows.
This commit is contained in:
@@ -61,13 +61,13 @@ public:
|
||||
delete properties;
|
||||
}
|
||||
|
||||
long APELocation;
|
||||
offset_t APELocation;
|
||||
long APESize;
|
||||
|
||||
long ID3v1Location;
|
||||
offset_t ID3v1Location;
|
||||
|
||||
ID3v2::Header *ID3v2Header;
|
||||
long ID3v2Location;
|
||||
offset_t ID3v2Location;
|
||||
long ID3v2Size;
|
||||
|
||||
TagUnion tag;
|
||||
@@ -310,7 +310,7 @@ void MPC::File::read(bool readProperties)
|
||||
|
||||
if(readProperties) {
|
||||
|
||||
long streamLength;
|
||||
offset_t streamLength;
|
||||
|
||||
if(d->APELocation >= 0)
|
||||
streamLength = d->APELocation;
|
||||
|
||||
@@ -66,14 +66,14 @@ public:
|
||||
// public members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
MPC::Properties::Properties(const ByteVector &data, long streamLength, ReadStyle style) :
|
||||
MPC::Properties::Properties(const ByteVector &data, offset_t streamLength, ReadStyle style) :
|
||||
AudioProperties(style),
|
||||
d(new PropertiesPrivate())
|
||||
{
|
||||
readSV7(data, streamLength);
|
||||
}
|
||||
|
||||
MPC::Properties::Properties(File *file, long streamLength, ReadStyle style) :
|
||||
MPC::Properties::Properties(File *file, offset_t streamLength, ReadStyle style) :
|
||||
AudioProperties(style),
|
||||
d(new PropertiesPrivate())
|
||||
{
|
||||
@@ -203,7 +203,7 @@ namespace
|
||||
const unsigned short sftable [8] = { 44100, 48000, 37800, 32000, 0, 0, 0, 0 };
|
||||
} // namespace
|
||||
|
||||
void MPC::Properties::readSV8(File *file, long streamLength)
|
||||
void MPC::Properties::readSV8(File *file, offset_t streamLength)
|
||||
{
|
||||
bool readSH = false, readRG = false;
|
||||
|
||||
@@ -295,7 +295,7 @@ void MPC::Properties::readSV8(File *file, long streamLength)
|
||||
}
|
||||
}
|
||||
|
||||
void MPC::Properties::readSV7(const ByteVector &data, long streamLength)
|
||||
void MPC::Properties::readSV7(const ByteVector &data, offset_t streamLength)
|
||||
{
|
||||
if(data.startsWith("MP+")) {
|
||||
if(data.size() < 4)
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#ifndef TAGLIB_MPCPROPERTIES_H
|
||||
#define TAGLIB_MPCPROPERTIES_H
|
||||
|
||||
#include "tbytevector.h"
|
||||
#include "taglib_export.h"
|
||||
#include "audioproperties.h"
|
||||
|
||||
@@ -53,13 +54,13 @@ namespace TagLib {
|
||||
*
|
||||
* This constructor is deprecated. It only works for MPC version up to 7.
|
||||
*/
|
||||
Properties(const ByteVector &data, long streamLength, ReadStyle style = Average);
|
||||
Properties(const ByteVector &data, offset_t streamLength, ReadStyle style = Average);
|
||||
|
||||
/*!
|
||||
* Create an instance of MPC::Properties with the data read directly
|
||||
* from a MPC::File.
|
||||
*/
|
||||
Properties(File *file, long streamLength, ReadStyle style = Average);
|
||||
Properties(File *file, offset_t streamLength, ReadStyle style = Average);
|
||||
|
||||
/*!
|
||||
* Destroys this MPC::Properties instance.
|
||||
@@ -146,8 +147,8 @@ namespace TagLib {
|
||||
Properties(const Properties &);
|
||||
Properties &operator=(const Properties &);
|
||||
|
||||
void readSV7(const ByteVector &data, long streamLength);
|
||||
void readSV8(File *file, long streamLength);
|
||||
void readSV7(const ByteVector &data, offset_t streamLength);
|
||||
void readSV8(File *file, offset_t streamLength);
|
||||
|
||||
class PropertiesPrivate;
|
||||
PropertiesPrivate *d;
|
||||
|
||||
Reference in New Issue
Block a user