From 838114d093af6c65c4717626b3e73b43c918dd02 Mon Sep 17 00:00:00 2001 From: Scott Wheeler Date: Wed, 18 Jul 2007 15:50:52 +0000 Subject: [PATCH] Fix SV4 MPC file length. (Read the length at the correct offset.) BUG:133959 git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@689576 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- taglib/mpc/mpcproperties.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/taglib/mpc/mpcproperties.cpp b/taglib/mpc/mpcproperties.cpp index 2d3f863c..4359281a 100644 --- a/taglib/mpc/mpcproperties.cpp +++ b/taglib/mpc/mpcproperties.cpp @@ -81,13 +81,6 @@ int MPC::Properties::sampleRate() const return d->sampleRate; } -/* -int MPC::Properties::sampleWidth() const -{ - return d->sampleWidth; -} -*/ - int MPC::Properties::channels() const { return d->channels; @@ -121,18 +114,21 @@ void MPC::Properties::read() d->channels = 2; } else { - unsigned int headerData = d->data.mid(0, 4).toUInt(false); + uint headerData = d->data.mid(0, 4).toUInt(false); + d->bitrate = (headerData >> 23) & 0x01ff; d->version = (headerData >> 11) & 0x03ff; d->sampleRate = 44100; d->channels = 2; + if(d->version >= 5) frames = d->data.mid(4, 4).toUInt(false); else - frames = d->data.mid(4, 2).toUInt(false); + frames = d->data.mid(6, 2).toUInt(false); } - unsigned int samples = frames * 1152 - 576; + uint samples = frames * 1152 - 576; + d->length = d->sampleRate > 0 ? (samples + (d->sampleRate / 2)) / d->sampleRate : 0; if(!d->bitrate)