mirror of
https://github.com/taglib/taglib.git
synced 2026-06-14 10:19:22 -04:00
Fix conversion compiler warnings
Using a release build with GCC 14.2.0 and -Wextra -Wconversion -Wall. The generated binaries are not changed by this commit.
This commit is contained in:
@@ -139,7 +139,7 @@ void APE::Properties::read(File *file, offset_t streamLength)
|
||||
if(d->sampleFrames > 0 && d->sampleRate > 0) {
|
||||
const auto length = static_cast<double>(d->sampleFrames) * 1000.0 / d->sampleRate;
|
||||
d->length = static_cast<int>(length + 0.5);
|
||||
d->bitrate = static_cast<int>(streamLength * 8.0 / length + 0.5);
|
||||
d->bitrate = static_cast<int>(static_cast<double>(streamLength) * 8.0 / length + 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -302,16 +302,16 @@ ByteVector ASF::Attribute::render(const String &name, int kind) const
|
||||
|
||||
if(kind == 0) {
|
||||
data = renderString(name, true) +
|
||||
ByteVector::fromShort(static_cast<int>(d->type), false) +
|
||||
ByteVector::fromShort(data.size(), false) +
|
||||
ByteVector::fromShort(static_cast<short>(d->type), false) +
|
||||
ByteVector::fromShort(static_cast<short>(data.size()), false) +
|
||||
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) +
|
||||
data = ByteVector::fromShort(static_cast<short>(kind == 2 ? d->language : 0), false) +
|
||||
ByteVector::fromShort(static_cast<short>(d->stream), false) +
|
||||
ByteVector::fromShort(static_cast<short>(nameData.size()), false) +
|
||||
ByteVector::fromShort(static_cast<short>(d->type), false) +
|
||||
ByteVector::fromUInt(data.size(), false) +
|
||||
nameData +
|
||||
data;
|
||||
|
||||
@@ -221,7 +221,8 @@ void ASF::File::FilePrivate::FilePropertiesObject::parse(ASF::File *file, long l
|
||||
|
||||
const long long duration = data.toLongLong(40, false);
|
||||
const long long preroll = data.toLongLong(56, false);
|
||||
file->d->properties->setLengthInMilliseconds(static_cast<int>(duration / 10000.0 - preroll + 0.5));
|
||||
file->d->properties->setLengthInMilliseconds(
|
||||
static_cast<int>(static_cast<double>(duration) / 10000.0 - static_cast<double>(preroll) + 0.5));
|
||||
}
|
||||
|
||||
ByteVector ASF::File::FilePrivate::StreamPropertiesObject::guid() const
|
||||
@@ -271,11 +272,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::fromShort(static_cast<short>(v1.size()), false));
|
||||
data.append(ByteVector::fromShort(static_cast<short>(v2.size()), false));
|
||||
data.append(ByteVector::fromShort(static_cast<short>(v3.size()), false));
|
||||
data.append(ByteVector::fromShort(static_cast<short>(v4.size()), false));
|
||||
data.append(ByteVector::fromShort(static_cast<short>(v5.size()), false));
|
||||
data.append(v1);
|
||||
data.append(v2);
|
||||
data.append(v3);
|
||||
@@ -302,7 +303,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::fromShort(static_cast<short>(attributeData.size()), false));
|
||||
data.append(attributeData.toByteVector(""));
|
||||
return BaseObject::render(file);
|
||||
}
|
||||
@@ -325,7 +326,7 @@ void ASF::File::FilePrivate::MetadataObject::parse(ASF::File *file, long long /*
|
||||
ByteVector ASF::File::FilePrivate::MetadataObject::render(ASF::File *file)
|
||||
{
|
||||
data.clear();
|
||||
data.append(ByteVector::fromShort(attributeData.size(), false));
|
||||
data.append(ByteVector::fromShort(static_cast<short>(attributeData.size()), false));
|
||||
data.append(attributeData.toByteVector(""));
|
||||
return BaseObject::render(file);
|
||||
}
|
||||
@@ -348,7 +349,7 @@ void ASF::File::FilePrivate::MetadataLibraryObject::parse(ASF::File *file, long
|
||||
ByteVector ASF::File::FilePrivate::MetadataLibraryObject::render(ASF::File *file)
|
||||
{
|
||||
data.clear();
|
||||
data.append(ByteVector::fromShort(attributeData.size(), false));
|
||||
data.append(ByteVector::fromShort(static_cast<short>(attributeData.size()), false));
|
||||
data.append(attributeData.toByteVector(""));
|
||||
return BaseObject::render(file);
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace TagLib
|
||||
{
|
||||
ByteVector data = str.data(String::UTF16LE) + ByteVector::fromShort(0, false);
|
||||
if(includeLength) {
|
||||
data = ByteVector::fromShort(data.size(), false) + data;
|
||||
data = ByteVector::fromShort(static_cast<short>(data.size()), false) + data;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ DSDIFF::Properties::Properties(unsigned int sampleRate,
|
||||
d->sampleRate = sampleRate;
|
||||
d->bitrate = bitrate;
|
||||
d->length = d->sampleRate > 0
|
||||
? static_cast<int>(d->sampleCount * 1000.0 / d->sampleRate + 0.5)
|
||||
? static_cast<int>(static_cast<double>(d->sampleCount) * 1000.0 / d->sampleRate + 0.5)
|
||||
: 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ bool DSF::File::isSupported(IOStream *stream)
|
||||
return id.startsWith("DSD ");
|
||||
}
|
||||
|
||||
DSF::File::File(FileName file, bool readProperties,
|
||||
DSF::File::File(FileName file, bool,
|
||||
AudioProperties::ReadStyle propertiesStyle,
|
||||
ID3v2::FrameFactory *frameFactory) :
|
||||
TagLib::File(file),
|
||||
@@ -69,7 +69,7 @@ DSF::File::File(FileName file, bool readProperties,
|
||||
read(propertiesStyle);
|
||||
}
|
||||
|
||||
DSF::File::File(IOStream *stream, bool readProperties,
|
||||
DSF::File::File(IOStream *stream, bool,
|
||||
AudioProperties::ReadStyle propertiesStyle,
|
||||
ID3v2::FrameFactory *frameFactory) :
|
||||
TagLib::File(stream),
|
||||
|
||||
@@ -129,6 +129,6 @@ void DSF::Properties::read(const ByteVector &data)
|
||||
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)
|
||||
? static_cast<unsigned int>(static_cast<double>(d->sampleCount) * 1000.0 / d->samplingFrequency + 0.5)
|
||||
: 0;
|
||||
}
|
||||
|
||||
@@ -321,7 +321,7 @@ public:
|
||||
return !file || !file->isValid();
|
||||
}
|
||||
|
||||
bool isNullWithDebugMessage(const String &methodName) const
|
||||
bool isNullWithDebugMessage([[maybe_unused]] const String &methodName) const
|
||||
{
|
||||
if(isNull()) {
|
||||
debug("FileRef::" + methodName + "() - Called without a valid file.");
|
||||
|
||||
@@ -274,7 +274,7 @@ bool FLAC::File::save()
|
||||
it = d->blocks.erase(it);
|
||||
continue;
|
||||
}
|
||||
blockHeader[0] = (*it)->code();
|
||||
blockHeader[0] = static_cast<char>((*it)->code());
|
||||
data.append(blockHeader);
|
||||
data.append(blockData);
|
||||
++it;
|
||||
|
||||
@@ -134,7 +134,7 @@ void FLAC::Properties::read(const ByteVector &data, offset_t streamLength)
|
||||
if(d->sampleFrames > 0 && d->sampleRate > 0) {
|
||||
const auto length = static_cast<double>(d->sampleFrames) * 1000.0 / d->sampleRate;
|
||||
d->length = static_cast<int>(length + 0.5);
|
||||
d->bitrate = static_cast<int>(streamLength * 8.0 / length + 0.5);
|
||||
d->bitrate = static_cast<int>(static_cast<double>(streamLength) * 8.0 / length + 0.5);
|
||||
}
|
||||
|
||||
if(data.size() >= pos + 16)
|
||||
|
||||
@@ -167,7 +167,7 @@ bool IT::File::save()
|
||||
if(messageOffset + messageLength >= fileSize) {
|
||||
// append new message
|
||||
seek(54);
|
||||
writeU16L(message.size());
|
||||
writeU16L(static_cast<unsigned short>(message.size()));
|
||||
writeU32L(messageOffset);
|
||||
seek(messageOffset);
|
||||
writeBlock(message);
|
||||
|
||||
@@ -400,7 +400,7 @@ Map<ByteVector, String> ItemFactory::namePropertyMap() const
|
||||
}
|
||||
|
||||
MP4::AtomDataList ItemFactory::parseData2(
|
||||
const MP4::Atom *atom, const ByteVector &data, int expectedFlags,
|
||||
const MP4::Atom *, const ByteVector &data, int expectedFlags,
|
||||
bool freeForm)
|
||||
{
|
||||
AtomDataList result;
|
||||
@@ -663,7 +663,7 @@ ByteVector ItemFactory::renderInt(
|
||||
const ByteVector &name, const MP4::Item &item)
|
||||
{
|
||||
ByteVectorList data;
|
||||
data.append(ByteVector::fromShort(item.toInt()));
|
||||
data.append(ByteVector::fromShort(static_cast<short>(item.toInt())));
|
||||
return renderData(name, TypeInteger, data);
|
||||
}
|
||||
|
||||
@@ -703,8 +703,8 @@ ByteVector ItemFactory::renderIntPair(
|
||||
{
|
||||
ByteVectorList data;
|
||||
data.append(ByteVector(2, '\0') +
|
||||
ByteVector::fromShort(item.toIntPair().first) +
|
||||
ByteVector::fromShort(item.toIntPair().second) +
|
||||
ByteVector::fromShort(static_cast<short>(item.toIntPair().first)) +
|
||||
ByteVector::fromShort(static_cast<short>(item.toIntPair().second)) +
|
||||
ByteVector(2, '\0'));
|
||||
return renderData(name, TypeImplicit, data);
|
||||
}
|
||||
@@ -714,8 +714,8 @@ ByteVector ItemFactory::renderIntPairNoTrailing(
|
||||
{
|
||||
ByteVectorList data;
|
||||
data.append(ByteVector(2, '\0') +
|
||||
ByteVector::fromShort(item.toIntPair().first) +
|
||||
ByteVector::fromShort(item.toIntPair().second));
|
||||
ByteVector::fromShort(static_cast<short>(item.toIntPair().first)) +
|
||||
ByteVector::fromShort(static_cast<short>(item.toIntPair().second)));
|
||||
return renderData(name, TypeImplicit, data);
|
||||
}
|
||||
|
||||
|
||||
@@ -196,7 +196,7 @@ MP4::Properties::read(File *file, const Atoms *atoms)
|
||||
}
|
||||
}
|
||||
if(unit > 0 && length > 0)
|
||||
d->length = static_cast<int>(length * 1000.0 / unit + 0.5);
|
||||
d->length = static_cast<int>(static_cast<double>(length) * 1000.0 / static_cast<double>(unit) + 0.5);
|
||||
|
||||
MP4::Atom *atom = trak->find("mdia", "minf", "stbl", "stsd");
|
||||
if(!atom) {
|
||||
|
||||
@@ -229,7 +229,7 @@ void MPC::Properties::readSV8(File *file, offset_t streamLength)
|
||||
frameCount > 0 && d->sampleRate > 0) {
|
||||
const auto length = static_cast<double>(frameCount) * 1000.0 / d->sampleRate;
|
||||
d->length = static_cast<int>(length + 0.5);
|
||||
d->bitrate = static_cast<int>(streamLength * 8.0 / length + 0.5);
|
||||
d->bitrate = static_cast<int>(static_cast<double>(streamLength) * 8.0 / length + 0.5);
|
||||
}
|
||||
}
|
||||
else if (packetType == "RG") {
|
||||
@@ -331,6 +331,6 @@ void MPC::Properties::readSV7(const ByteVector &data, offset_t streamLength)
|
||||
d->length = static_cast<int>(length + 0.5);
|
||||
|
||||
if(d->bitrate == 0)
|
||||
d->bitrate = static_cast<int>(streamLength * 8.0 / length + 0.5);
|
||||
d->bitrate = static_cast<int>(static_cast<double>(streamLength) * 8.0 / length + 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ void ID3v1::Tag::setComment(const String &s)
|
||||
|
||||
void ID3v1::Tag::setGenre(const String &s)
|
||||
{
|
||||
d->genre = ID3v1::genreIndex(s);
|
||||
d->genre = static_cast<unsigned char>(ID3v1::genreIndex(s));
|
||||
}
|
||||
|
||||
void ID3v1::Tag::setYear(unsigned int i)
|
||||
@@ -186,7 +186,7 @@ void ID3v1::Tag::setYear(unsigned int i)
|
||||
|
||||
void ID3v1::Tag::setTrack(unsigned int i)
|
||||
{
|
||||
d->track = i < 256 ? i : 0;
|
||||
d->track = static_cast<unsigned char>(i < 256 ? i : 0);
|
||||
}
|
||||
|
||||
unsigned int ID3v1::Tag::genreNumber() const
|
||||
@@ -196,7 +196,7 @@ unsigned int ID3v1::Tag::genreNumber() const
|
||||
|
||||
void ID3v1::Tag::setGenreNumber(unsigned int i)
|
||||
{
|
||||
d->genre = i < 256 ? i : 255;
|
||||
d->genre = static_cast<unsigned char>(i < 256 ? i : 255);
|
||||
}
|
||||
|
||||
void ID3v1::Tag::setStringHandler(const StringHandler *handler)
|
||||
|
||||
@@ -240,7 +240,7 @@ void MPEG::Properties::read(File *file, ReadStyle readStyle)
|
||||
const Header lastHeader(file, lastFrameOffset, false);
|
||||
if(const offset_t streamLength = lastFrameOffset - firstFrameOffset + lastHeader.frameLength();
|
||||
streamLength > 0)
|
||||
d->length = static_cast<int>(streamLength * 8.0 / d->bitrate + 0.5);
|
||||
d->length = static_cast<int>(static_cast<double>(streamLength) * 8.0 / d->bitrate + 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ void Opus::Properties::read(File *file)
|
||||
fileLengthWithoutOverhead -= file->packet(i).size();
|
||||
}
|
||||
d->length = static_cast<int>(length + 0.5);
|
||||
d->bitrate = static_cast<int>(fileLengthWithoutOverhead * 8.0 / length + 0.5);
|
||||
d->bitrate = static_cast<int>(static_cast<double>(fileLengthWithoutOverhead) * 8.0 / length + 0.5);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -163,7 +163,7 @@ void Speex::Properties::read(File *file)
|
||||
fileLengthWithoutOverhead -= file->packet(i).size();
|
||||
}
|
||||
d->length = static_cast<int>(length + 0.5);
|
||||
d->bitrate = static_cast<int>(fileLengthWithoutOverhead * 8.0 / length + 0.5);
|
||||
d->bitrate = static_cast<int>(static_cast<double>(fileLengthWithoutOverhead) * 8.0 / length + 0.5);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -166,7 +166,7 @@ void Vorbis::Properties::read(File *file)
|
||||
fileLengthWithoutOverhead -= file->packet(i).size();
|
||||
}
|
||||
d->length = static_cast<int>(length + 0.5);
|
||||
d->bitrate = static_cast<int>(fileLengthWithoutOverhead * 8.0 / length + 0.5);
|
||||
d->bitrate = static_cast<int>(static_cast<double>(fileLengthWithoutOverhead) * 8.0 / length + 0.5);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -196,7 +196,7 @@ bool Shorten::File::isSupported(IOStream *stream)
|
||||
return id.startsWith("ajkg");
|
||||
}
|
||||
|
||||
Shorten::File::File(FileName file, bool readProperties,
|
||||
Shorten::File::File(FileName file, bool,
|
||||
AudioProperties::ReadStyle propertiesStyle) :
|
||||
TagLib::File(file),
|
||||
d(std::make_unique<FilePrivate>())
|
||||
@@ -205,7 +205,7 @@ Shorten::File::File(FileName file, bool readProperties,
|
||||
read(propertiesStyle);
|
||||
}
|
||||
|
||||
Shorten::File::File(IOStream *stream, bool readProperties,
|
||||
Shorten::File::File(IOStream *stream, bool,
|
||||
AudioProperties::ReadStyle propertiesStyle) :
|
||||
TagLib::File(stream),
|
||||
d(std::make_unique<FilePrivate>())
|
||||
|
||||
@@ -65,7 +65,7 @@ Shorten::Properties::Properties(const PropertyValues *values, ReadStyle style) :
|
||||
|
||||
d->bitrate = static_cast<int>(d->sampleRate * d->bitsPerSample * d->channelCount / 1000.0 + 0.5);
|
||||
if(d->sampleRate > 0)
|
||||
d->length = static_cast<int>(d->sampleFrames * 1000.0 / d->sampleRate + 0.5);
|
||||
d->length = static_cast<int>(static_cast<double>(d->sampleFrames) * 1000.0 / d->sampleRate + 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +120,8 @@ T toNumber(const ByteVector &v, size_t offset, size_t length, bool mostSignifica
|
||||
T sum = 0;
|
||||
for(size_t i = 0; i < length; i++) {
|
||||
const size_t shift = (mostSignificantByteFirst ? length - 1 - i : i) * 8;
|
||||
sum |= static_cast<T>(static_cast<unsigned char>(v[static_cast<int>(offset + i)])) << shift;
|
||||
sum |= static_cast<T>(
|
||||
static_cast<T>(static_cast<unsigned char>(v[static_cast<int>(offset + i)])) << shift);
|
||||
}
|
||||
|
||||
return sum;
|
||||
|
||||
@@ -145,7 +145,7 @@ void TrueAudio::Properties::read(const ByteVector &data, offset_t streamLength)
|
||||
if(d->sampleFrames > 0 && d->sampleRate > 0) {
|
||||
const auto length = static_cast<double>(d->sampleFrames) * 1000.0 / d->sampleRate;
|
||||
d->length = static_cast<int>(length + 0.5);
|
||||
d->bitrate = static_cast<int>(streamLength * 8.0 / length + 0.5);
|
||||
d->bitrate = static_cast<int>(static_cast<double>(streamLength) * 8.0 / length + 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ void WavPack::Properties::read(File *file, offset_t streamLength)
|
||||
if(d->version < MIN_STREAM_VERS || d->version > MAX_STREAM_VERS)
|
||||
break;
|
||||
|
||||
d->bitsPerSample = ((flags & BYTES_STORED) + 1) * 8 - ((flags & SHIFT_MASK) >> SHIFT_LSB);
|
||||
d->bitsPerSample = static_cast<int>(((flags & BYTES_STORED) + 1) * 8 - ((flags & SHIFT_MASK) >> SHIFT_LSB));
|
||||
d->sampleRate = static_cast<int>(smplRate);
|
||||
d->lossless = !(flags & HYBRID_FLAG);
|
||||
d->sampleFrames = smplFrames;
|
||||
@@ -308,7 +308,7 @@ void WavPack::Properties::read(File *file, offset_t streamLength)
|
||||
if(d->sampleFrames > 0 && d->sampleRate > 0) {
|
||||
const auto length = static_cast<double>(d->sampleFrames) * 1000.0 / d->sampleRate;
|
||||
d->length = static_cast<int>(length + 0.5);
|
||||
d->bitrate = static_cast<int>(streamLength * 8.0 / length + 0.5);
|
||||
d->bitrate = static_cast<int>(static_cast<double>(streamLength) * 8.0 / length + 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -560,7 +560,7 @@ public:
|
||||
// reverse
|
||||
{
|
||||
for(int i = 0; i < 256; i++){
|
||||
all[i]=static_cast<unsigned char>(255)-i;
|
||||
all[i]=static_cast<unsigned char>(255 - i);
|
||||
}
|
||||
ByteVector b64 = all.toBase64();
|
||||
ByteVector original = ByteVector::fromBase64(b64);
|
||||
|
||||
Reference in New Issue
Block a user