From: Scott Wheeler Date: Thu, 12 Sep 2019 10:13:24 +0000 (+0200) Subject: Correctly decode signed values X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ebd3373d6d230f45cfb616b5af29b441126c4bb1;p=taglib Correctly decode signed values In SV7 these are a mix of signed and unsigned shorts; in SV8 they're all signed. Storing them as an int is fine for signed or unsigned shorts as it's wide enough to contain either of them. Unfortunately there are no explicit tests for SV7 at the moment; that would be ideal to add before the next release. CC @carewolf --- diff --git a/taglib/mpc/mpcproperties.cpp b/taglib/mpc/mpcproperties.cpp index 24e35c78..21de6d49 100644 --- a/taglib/mpc/mpcproperties.cpp +++ b/taglib/mpc/mpcproperties.cpp @@ -49,17 +49,17 @@ public: albumGain(0), albumPeak(0) {} - int version; - int length; - int bitrate; - int sampleRate; - int channels; + int version; + int length; + int bitrate; + int sampleRate; + int channels; unsigned int totalFrames; unsigned int sampleFrames; - unsigned int trackGain; - unsigned int trackPeak; - unsigned int albumGain; - unsigned int albumPeak; + int trackGain; + int trackPeak; + int albumGain; + int albumPeak; }; //////////////////////////////////////////////////////////////////////////////// @@ -311,9 +311,9 @@ void MPC::Properties::readSV7(const ByteVector &data, long streamLength) const unsigned int gapless = data.toUInt(5, false); d->trackGain = data.toShort(14, false); - d->trackPeak = data.toShort(12, false); + d->trackPeak = data.toUShort(12, false); d->albumGain = data.toShort(18, false); - d->albumPeak = data.toShort(16, false); + d->albumPeak = data.toUShort(16, false); // convert gain info if(d->trackGain != 0) {