]> granicus.if.org Git - taglib/commitdiff
Correctly decode signed values
authorScott Wheeler <scott@directededge.com>
Thu, 12 Sep 2019 10:13:24 +0000 (12:13 +0200)
committerScott Wheeler <scott@directededge.com>
Thu, 12 Sep 2019 10:13:24 +0000 (12:13 +0200)
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

taglib/mpc/mpcproperties.cpp

index 24e35c7856e1b91f4ef7887c7dcb2e5b23efd0b3..21de6d495d82ba8aa8c325c3d21120eb445c0f72 100644 (file)
@@ -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) {