Ignoring the cover on some tracks

Thomas Post post at equinux.com
Mon Mar 29 16:20:29 CEST 2010


Hi,

I have some (maybe corrupt) mp4 tracks that have an cover. The cover part contains a 'data' atom and afterwards a 'name' atom. This has the effect that the following method returns without adding a cover.

MP4::Tag::parseCovr(MP4::Atom *atom, TagLib::File *file)
{
  MP4::CoverArtList value;
  ByteVector data = file->readBlock(atom->length - 8);
  unsigned int pos = 0;
  while(pos < data.size()) {
    int length = data.mid(pos, 4).toUInt();
    ByteVector name = data.mid(pos + 4, 4);
    int flags = data.mid(pos + 8, 4).toUInt();
    if(name != "data") {
      debug("MP4: Unexpected atom \"" + name + "\", expecting \"data\"");
      return;
    }
    if(flags == MP4::CoverArt::PNG || flags == MP4::CoverArt::JPEG) {
      value.append(MP4::CoverArt(MP4::CoverArt::Format(flags),
                                 data.mid(pos + 16, length - 16)));
    }
    pos += length;
  }
  if(value.size() > 0)
    d->items.insert(atom->name, value);
}

 
So the return in the if(name != "data")... should be a break right? That would ignore the unexpected atom but still adds the maybe previously correct parsed 'data' atom to d->items. Because (at least) iTunes can read the covers from these tracks.
  
Thomas Post
-----------------------------------------------------------------------------------------------------------

equinux Aktiengesellschaft
Informationstechnologien
Kirschstraße 35
80999 München - Germany
Tel. +49-89-520465-339
Fax +49-89-520465-299
mailto:post at equinux.de
http://www.equinux.com/de
-----------------------------------------------------------------------------------------------------------
Vorstand: Till Schadde  -  Aufsichtsrat: Stefan Neuenhahn
USt-IdNr.: DE206360115  -  Sitz München  -  HRB München 129700
-----------------------------------------------------------------------------------------------------------

equinux USA, Inc.
100 Produce Ave. Suite L, South San Francisco, CA 94080 
Toll free: 1-888-equinux (1-888-3784689)
http://www.equinux.com
-----------------------------------------------------------------------------------------------------------

Stay updated what's going on at equinux
equinux Blog | equinux @ Twitter | equinux @ Facebook

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/taglib-devel/attachments/20100329/75d20663/attachment.htm 


More information about the taglib-devel mailing list