mirror of
https://github.com/taglib/taglib.git
synced 2026-01-22 08:13:39 -05:00
Set last header flag in FLAC Metadata block type field
In case the Vorbis comment block is the last one the last block flag has to be set. As the other metadata blocks are kept as is, and in original order, and no other metadata blocks are added/inserted, these can be kept as is. Also warn if the header scan loop detects a frame sync sequence (which is the head of the first non-header packet). Previously, this was detected as the last header packet, but streamStart and streamLength are unused, and all packets but the vorbis comment packet are just copied in order. See taglib#1297
This commit is contained in:
committed by
Urs Fleisch
parent
c67e434939
commit
70c6a0c75f
@ -46,6 +46,7 @@ public:
|
||||
|
||||
bool hasXiphComment { false };
|
||||
int commentPacket { 0 };
|
||||
int lastHeaderPacket { 0 };
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -129,6 +130,12 @@ bool Ogg::FLAC::File::save()
|
||||
|
||||
v[0] = 4;
|
||||
|
||||
// If the comment block is the last one, set the corresponding bit
|
||||
|
||||
if (d->commentPacket == d->lastHeaderPacket) {
|
||||
v[0] = static_cast<char>(0x84);
|
||||
}
|
||||
|
||||
// Append the comment-data after the 32 bit header
|
||||
|
||||
v.append(d->xiphCommentData);
|
||||
@ -282,6 +289,12 @@ void Ogg::FLAC::File::scan()
|
||||
return;
|
||||
}
|
||||
|
||||
if(((header[0] & 0xff) == 0xff) && ((header[1] & 0xff) == 0xf8)) {
|
||||
ipacket--;
|
||||
debug("Ogg::FLAC::File::scan() -- Found frame sync marker, possibly missing last block marker");
|
||||
break;
|
||||
}
|
||||
|
||||
blockType = header[0] & 0x7f;
|
||||
lastBlock = (header[0] & 0x80) != 0;
|
||||
length = header.toUInt(1, 3, true);
|
||||
@ -315,6 +328,7 @@ void Ogg::FLAC::File::scan()
|
||||
debug("Ogg::FLAC::File::scan() -- Unknown metadata block");
|
||||
}
|
||||
}
|
||||
d->lastHeaderPacket = ipacket;
|
||||
|
||||
// End of metadata, now comes the datastream
|
||||
d->streamStart = overhead;
|
||||
|
||||
Reference in New Issue
Block a user