APIC frame for ID3v2.2

Richard Low richard at wentnet.com
Sun Mar 15 15:03:08 CET 2009


Hi all,

It seems as though taglib assumes that the APIC frame is for ID3  
version 2.3 or above, yet the format is different for v2.2.  I've  
modified attachedpictureframe.cpp to check for v2.2. frames.  Below is  
a working AttachedPictureFrame::parseFields() (also attached as a  
patch against latest in SVN repository).

Thanks a lot for taglib - it's by far the best tagging library I've  
seen.

Richard.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: attachedpictureframe.diff
Type: application/octet-stream
Size: 1681 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/taglib-devel/attachments/20090315/c766da7a/attachment.dll 
-------------- next part --------------



void AttachedPictureFrame::parseFields(const ByteVector &data)
{
   if (this->header()->version() == 2)
   {
     if(data.size() < 7) {
       debug("A picture frame must contain at least 7 bytes.");
       return;
     }

     int pos = 0;
     d->textEncoding = String::Type(data[pos]);
     pos += 1;

     d->mimeType = String(data.mid(pos, 3), String::Latin1);
     pos += 3;

     d->type = (TagLib::ID3v2::AttachedPictureFrame::Type)data[pos];
     pos += 1;

     d->description = readStringField(data, d->textEncoding, &pos);

     d->data = data.mid(pos);
   }
   else
   {
     if(data.size() < 5) {
       debug("A picture frame must contain at least 5 bytes.");
       return;
     }

     d->textEncoding = String::Type(data[0]);

     int pos = 1;

     d->mimeType = readStringField(data, String::Latin1, &pos);
     d->type = (TagLib::ID3v2::AttachedPictureFrame::Type)data[pos++];
     d->description = readStringField(data, d->textEncoding, &pos);

     d->data = data.mid(pos);
   }
}



More information about the taglib-devel mailing list