mirror of
https://github.com/taglib/taglib.git
synced 2025-05-27 21:20:26 -04:00
Use the new replace function. (Doing in-place value modifications isn't done anywhere else in the
TagLib API, so let's not do it here either...) git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@771465 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
This commit is contained in:
parent
5542dbb94b
commit
2644c529a5
@ -116,7 +116,7 @@ Frame *FrameFactory::createFrame(const ByteVector &origData, Header *tagHeader)
|
||||
// Data lengths are not part of the encoded data, but since they are synch-safe
|
||||
// integers they will be never actually encoded.
|
||||
ByteVector frameData = data.mid(Frame::Header::size(version), header->frameSize());
|
||||
SynchData::decode(frameData);
|
||||
frameData = SynchData::decode(frameData);
|
||||
data = data.mid(0, Frame::Header::size(version)) + frameData;
|
||||
}
|
||||
|
||||
|
@ -51,22 +51,13 @@ ByteVector SynchData::fromUInt(uint value)
|
||||
return v;
|
||||
}
|
||||
|
||||
void SynchData::decode(ByteVector &data)
|
||||
ByteVector SynchData::decode(const ByteVector &data)
|
||||
{
|
||||
char *n = data.data();
|
||||
const char *o = data.data();
|
||||
const char *end = o + data.size();
|
||||
ByteVector result = data;
|
||||
|
||||
if(data.size() <= 0)
|
||||
return;
|
||||
ByteVector pattern(2, char(0));
|
||||
pattern[0] = '\xFF';
|
||||
pattern[1] = '\x00';
|
||||
|
||||
while(o < end - 1) {
|
||||
*n++ = *o;
|
||||
if(o[0] == '\xFF' && o[1] == '\x00')
|
||||
o++;
|
||||
o++;
|
||||
}
|
||||
*n++ = *o;
|
||||
|
||||
data.resize(n - data.data());
|
||||
return result.replace(pattern, '\xFF');
|
||||
}
|
||||
|
@ -59,9 +59,9 @@ namespace TagLib {
|
||||
TAGLIB_EXPORT ByteVector fromUInt(uint value);
|
||||
|
||||
/*!
|
||||
* Deunsynchronize the data (in-place).
|
||||
* Convert the data from unsynchronized data to its original format.
|
||||
*/
|
||||
TAGLIB_EXPORT void decode(ByteVector &data);
|
||||
TAGLIB_EXPORT ByteVector decode(const ByteVector &input);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -395,9 +395,8 @@ void ID3v2::Tag::parse(const ByteVector &origData)
|
||||
{
|
||||
ByteVector data = origData;
|
||||
|
||||
if(d->header.unsynchronisation() && d->header.majorVersion() <= 3) {
|
||||
SynchData::decode(data);
|
||||
}
|
||||
if(d->header.unsynchronisation() && d->header.majorVersion() <= 3)
|
||||
data = SynchData::decode(data);
|
||||
|
||||
uint frameDataPosition = 0;
|
||||
uint frameDataLength = data.size();
|
||||
|
Loading…
Reference in New Issue
Block a user